AndreasSchmitt
30th April 2008, 12:49
I'm trying to develop an ASCII Menu System for ERP-LN to start 3GL sessions from it. We are using a lot of telnet based WLAN Scan-Devices running BaanIV-3GL session. What we are missing in LN is the good old menu system.
I've developed a 3GL ASCII-Session implememting a menu - works fine ! :)
From the menu I can start various sessions via activate("Programm.Name") but I have to close the called session if I want to get back to the menu. :( Task switching - via hot key - between running 3GL sessions is no possible. :mad:
Is anybody out there who kows how to work with this program groups for event handling and the other stuff for parallelizing the sessions? :confused:

Many thanks in advance for any response ...

dharam.dv
30th April 2008, 12:55
Can you send the code of it.

Regards
Dharam

AndreasSchmitt
30th April 2008, 14:10
The menu is still very experimental, only 1 program is called when you press <return> but for testing purposes this should be enough ! ;)


|******************************************************************************
|* tccom9000 0 VRC B61C a echt
|* Menusystem for 3GL Sessions - Still very experimental
|* as
|* 29.04.08 [11:09]
|******************************************************************************
|* Script Type: 0
|******************************************************************************

#ident "@(#)tccom9000 tcB61Caecht s1erp3 Rev.No. 2 29 Apr 08 AS"

#include <bic_tt>
#include <bic_dam>
|/ #include "itcmcs2000" |* DAL(-GUI) Support Defines

long event(EVTMAXSIZE)
long menu.win
long sub.win
long sub.pid
long px
long py
long prog.run
long num.key
long i
long me
long last.menu.cursor

#define FIRSTMENU 3
#define MAXMENU 12
long LASTMENU


STRING menu.entries(16,MAXMENU) |/ 10 Strings of length 16
STRING menu.keys(1,MAXMENU)

function main()
{
prog.run = 1

|/ Menu should be placed into a database table ...

menu.entries(1,1) = "Programm 1"
menu.entries(1,2) = "Programm 2"
menu.entries(1,3) = "Programm 3"
menu.entries(1,4) = "Programm 4"
menu.entries(1,5) = "Programm 5"
menu.entries(1,6) = "Programm 6"
menu.entries(1,7) = "Programm 7"
menu.entries(1,8) = "Programm 8"
menu.entries(1,9) = "Programm 9"
menu.entries(1,10) = "Programm 10"

menu.keys(1,1) = "1"
menu.keys(1,2) = "2"
menu.keys(1,3) = "3"
menu.keys(1,4) = "4"
menu.keys(1,5) = "5"
menu.keys(1,6) = "6"
menu.keys(1,7) = "7"
menu.keys(1,8) = "a"
menu.keys(1,9) = "x"
menu.keys(1,10) = "z"

menu.win = new.window(16, 20, 1, 1)

px = 2
py = 2

display.empty.form()

for i=1 to 10 step 1
print cp$(px,py+i), "(" & menu.keys(1,i) & ") " & menu.entries(1,i)
LASTMENU = py+i
endfor
refresh()

last.menu.cursor = FIRSTMENU
menu.cursor(FIRSTMENU)

px = 10
py = 16
print cp$(px,py), " "
refresh()

while( prog.run = 1)
next.event(event)

on case evt.type(event)
case EVTKEYPRESS:
print cp$(px,py), " "
num.key = evt.keypress.key(event)
on case num.key
case KEY_RETURN:
print cp$(px,py), "return"
refresh()

|/ This call works but doesnt allow switch back to menu ....
activate("owhinh9132")

|/ This stuff doesnt work ....

|/ sub.win = create.mwindow( menu.win, 16, 20, 1, 1)
|/ change.mwindow(sub.win)
|/ sub.pid = act.and.sleep( "owhinh9132")
|/ if(sub.pid)then
|/ set.pgrp(sub.pid, sub.pid)
|/ grab.mwindow( sub.win, sub.pid)
|/ reactivate(sub.pid)
|/ endif
|/ change.mwindow( menu.win)
|/
|/ print cp$(px,py), me
refresh()
break
case KEY_ESC:
print cp$(px,py), "esc"
refresh()
suspend(500)
print cp$(px,py), "exiting program ..."
refresh()
suspend(200)
prog.run = 0
break
case KEY_TAB:
case KEY_DOWN:
me = menu.cursor(last.menu.cursor+1)
print cp$(px,py), menu.entries( 1, me;11)
print cp$(px,py)
refresh()
break
case KEY_BACKTAB:
case KEY_UP:
me = menu.cursor(last.menu.cursor-1)
print cp$(px,py), menu.entries( 1, me;11)
print cp$(px,py)
refresh()
break
default:
me = is.menu.key(num.key)
if( me > 0 ) then
menu.cursor(me+2)
print cp$(px,py), menu.entries( 1, me;11)
print cp$(px,py)
refresh()
endif
endcase
endcase
endwhile
end.prog()
}



function long is.menu.key( long nk)
{
long ret
long i

ret = 0

for i=1 to LASTMENU step 1
if( asc(menu.keys(1,i)) = nk ) then
ret = i
endif
endfor
return( ret)
}

function long menu.cursor( long pos.y)
{
if(pos.y > LASTMENU) then
pos.y = FIRSTMENU
endif

if(pos.y < FIRSTMENU) then
pos.y = LASTMENU
endif

print cp$( 5, last.menu.cursor), " "
print cp$( 19, last.menu.cursor), " "

print cp$( 5, pos.y), "<"
print cp$( 19, pos.y), ">"
refresh()

last.menu.cursor = pos.y
return( pos.y - 2)
}


function end.prog()
{
if ( menu.win ) then
del.window(menu.win)
endif

end()
}

function display.empty.form()
{
print cp$(01,01), " ERPLN-Menu - 1dv05 "
print cp$(01,02), " "
print cp$(01,03), " "
print cp$(01,04), " "
print cp$(01,05), " "
print cp$(01,06), " "
print cp$(01,07), " "
print cp$(01,08), " "
print cp$(01,09), " "
print cp$(01,10), " "
print cp$(01,11), " "
print cp$(01,12), " "
print cp$(01,13), " "
print cp$(01,14), " "
print cp$(01,15), " "
print cp$(01,16), " Auswahl: "

refresh()
}

NPRao
1st May 2008, 02:21
I'm trying to develop an ASCII Menu System for ERP-LN to start 3GL sessions from it. We are using a lot of telnet based WLAN Scan-Devices running BaanIV-3GL session. What we are missing in LN is the good old menu system.
I've developed a 3GL ASCII-Session implememting a menu - works fine !
I am not sure how the WLAN Scan Devices are interacting with the Baan menu and activating the choice.
You can add 3-GL programs in the menu structure in the LN Tools.

Your program looks good. :)

Try adding another statement -
activate("owhinh9132")
reactivate(pid)

If that doesn't work, you can try this option - Making related processes independent (http://www.baanboard.com/programmers_manual_baanerp_help_multitasking_processes_process_groups_and_main_windows)

Is anybody out there who kows how to work with this program groups for event handling and the other stuff for parallelizing the sessions?
Refer to the link - substitute.session() (http://www.baanboard.com/programmers_manual_baanerp_help_functions_substitute_sessions_substitute_session)

AndreasSchmitt
5th May 2008, 09:44
@NPRao: The Scan Devices run simple telnet sessions.

We need to run multiple BaanLN Sessions (3GL/ASCII) simultaneously, having a 'hot-key' to switch between this session. In BaanIV this was quit simple with the standard menu (Function Key) that is no longer there in LN. I 've read 'Making related processes independent' but i don't know how to get it working - I always get error messages when I try to start a session. :(

If there is anybody how has a 'working example' for this 'independent session thing' I would be glad to hear from you !

AndreasSchmitt
13th May 2008, 10:53
Is there nobody who has experience with this 'session Group thing' in 3GL Programs ? :( - Can't believe that ... ;)

NPRao
24th May 2008, 06:20
Andreas,

I tested your code with the list of the sessions and found that the focus is now changed to the new sessions called by the 3-GL menu. I used act.and.sleep() so the new child processes are started and put in the sleeping queue in the background.

Here is the updated version, with some more colors feature, which compiles good in LN Tools.

#define STARTPOS 4
#define MAXMENU 12
|***************************************************************************
long menu.win
string menu.entries(16, MAXMENU), menu.keys(1, MAXMENU)
|***************************************************************************
function main()
{
boolean prog.run
long posn, counter, px, py, num.key, prev.posn, last.posn
long child.pid, event(EVTMAXSIZE)

prog.run = true
init.values()
px = 8
py = 3
for counter = 1 to 10 step 1
print.line(px, py + counter, "(" & menu.keys(1, counter) & ") " &
menu.entries(1, counter) & " " &
tt.session.desc(menu.entries(1, counter)))
last.posn = py + counter
endfor
print fg$(CW.WHITE)
prev.posn = STARTPOS
print.line(12, prev.posn, menu.entries(1, 1), true)
px = 20
py = 20
print cp$(px, py), " "
while(prog.run)
next.event(event)
if evt.type(event) = EVTKEYPRESS then
footer.line(" ")
num.key = evt.keypress.key(event)
on case num.key
case KEY_RETURN:
footer.line("Return")
child.pid = act.and.sleep(
menu.entries(1, prev.posn - 3))
refresh()
break
case KEY_ESC:
footer.line("ESC")
suspend(500)
footer.line("Exiting Program...")
suspend(200)
prog.run = false
break
case KEY_TAB:
case KEY_DOWN:
print.line(12, prev.posn,
menu.entries(1, prev.posn - 3))
posn = posn + 1
if posn > last.posn then
posn = STARTPOS
endif
if posn < STARTPOS then
posn = last.posn
endif
prev.posn = posn
print.line(12, prev.posn,
menu.entries(1, posn - 3), true)
break
case KEY_BACKTAB:
case KEY_UP:
print.line(12, prev.posn,
menu.entries(1, prev.posn -3))
posn = posn - 1
if posn > last.posn then
posn = STARTPOS
endif
if posn < STARTPOS then
posn = last.posn
endif
prev.posn = posn
print.line(12, prev.posn,
menu.entries(1, posn - 3), true)
break
default:
posn = 0
print.line(12, prev.posn,
menu.entries(1, prev.posn - 3))
for counter = 1 to (last.posn - 3) step 1
if(asc(menu.keys(1, counter)) =
num.key) then
posn = counter
endif
endfor
if posn > 0 then
print.line(12, posn + 3,
menu.entries(1, posn), true)
footer.line(menu.entries(1, posn))
print cp$(10, 20)
refresh()
endif
prev.posn = posn + 3
endcase
endif
endwhile
if menu.win > 0 then
del.window(menu.win)
endif
}
|***************************************************************************
function init.values()
{
boolean bret
domain ttdsca username

menu.entries(1,1) = "ttadv2500m000"
menu.entries(1,2) = "ttadv3530m000"
menu.entries(1,3) = "ttaad2500m000"
menu.entries(1,4) = "ttams2100m000"
menu.entries(1,5) = "ttaad1100m000"
menu.entries(1,6) = "ttadv3560m000"
menu.entries(1,7) = "ttadv4500m000"
menu.entries(1,8) = "ttadv4520m000"
menu.entries(1,9) = "ttadv4551m000"
menu.entries(1,10) = "ttadv4561m000"

menu.keys(1,1) = "1"
menu.keys(1,2) = "2"
menu.keys(1,3) = "3"
menu.keys(1,4) = "4"
menu.keys(1,5) = "5"
menu.keys(1,6) = "6"
menu.keys(1,7) = "7"
menu.keys(1,8) = "8"
menu.keys(1,9) = "9"
menu.keys(1,10) = "0"

menu.win = new.window(23, 80, 1, 1)
print fg$(CW.CYAN)
box(1, 1, 80, 3, 0)
print fg$(CW.WHITE)
bret = tt.user(logname$, username)
print cp$(10, 2), cf$(1), "ERP_LN_Menu" & string.set$(" ",10) &
username, cf$(0)
print cp$(01, 20), " Choice: "
}
|***************************************************************************
function print.line(long x, long y, const string strg(),
[boolean font.option])
{
FUNCTIONUSAGE
input positions, string,
font.option: true - Underscore & bold, else - normal
ENDFUNCTIONUSAGE

if get.argc() = 4 then
font.option = get.boolean.arg(4)
else
font.option = false
endif
if font.option then
print fg$(CW.BLUE)
print cp$(x, y), cf$(9), strg, cf$(0)
footer.line(strg)
else
print fg$(CW.CYAN)
print cp$(x, y), cf$(0), strg, cf$(0)
endif
refresh()
}
|***************************************************************************
function footer.line(const string strg())
{
FUNCTIONUSAGE
print input string as footer line
ENDFUNCTIONUSAGE

print fg$(CW.CYAN)
print cp$(10, 20), cf$(2), sprintf$("%-30s", strg), cf$(0)
refresh()
}
|******************************************************************************

We need to run multiple BaanLN Sessions (3GL/ASCII) simultaneously, having a 'hot-key' to switch between this session.
To get this feature working, you have to store the child.pid into a array variable and create a new hot-key option, then to display the child processes and when a particular process is selected, call the reactivate(child.pid(i)) to switch to that process, a process tree view like ottgbfprocess would be a good interface. The only issue I found in this approach is that, if you opened a few child process and then try to exit the 3-GL menu application it waits for them to finish. You can explore using signal()s to avoid that. I noticed that ottgbfprocess always has a parent process id 0 when I started it from the status bar and has a parent process id when I start from the run program.
Have to explore something later, interesting program... :)

AndreasSchmitt
5th June 2008, 13:07
Sorry for answering this late ! But I was busy with some other stuff. Thanks a lot for couloring the menu - but my main problem isn't jet solved. If I act.and.sleep() and afterwards reactivate() an other 3gl session from the menu
the called session is displayed but every key-press seems to be routed through the menu application ... after a few key-presses the menu application terminates fatal. :( I'll to some investigations on this thing .... :confused:
I don't see how to switch between different session in your suggestion ...
by Andreas