Hi,
1. If the data comes from a lookup for customer name field; it would be better to activate the popup in the before field part of the input statement. In the after field section, issue a next field statement and transfer the control to next logical input field. This way user will save many key taps (control-z etc.)
2. Here is a sample 4gl program and form source code, which activates a lookup window (popup) and jumps to a location as requeted by an user. DISPLAY ARRAY uses hotkey F1 or control-w to get the alpha/expression (could be more than one character) from an user and jumps into very first occurance of data using FGL_SETCURRLINE() in-built function (version 7.3 feature).
--popup.4gl
database testdb
main
call popup()
end main
function popup()
define cmd char(500),
test_arr array[900] of
record
menu_item like systables.tabname
end record,
i,j,k int, expr,alpha,p_alpha varchar(10)
let k=10 --number of characters needed as item hot keys, initialize this with 1 if you need to only the first alpha as a hot key to be trapped.
options form line first, prompt line last
let cmd="select tabname from systables where tabid>99 order by 1"
prepare id1 from cmd
declare cur1 cursor for id1
free id1
create temp table x (alpha varchar(10), lno int) with no log
let cmd="select lno from x where alpha matches ?"
prepare id2 from cmd
declare popcur cursor for id2
free id2
let i=1
let p_alpha="!"
open cur1
while(1)
fetch cur1 into test_arr.*
if status=notfound then
exit while
end if
let alpha = test_arr.menu_item[1,k]
if alpha != p_alpha then
insert into x values (alpha,i)
let p_alpha= alpha
end if
let i=i+1
if i>900 then exit while end if
end while
call set_count(i-1)
close cur1
open window w1 at 2,5 with form "popup"
display array test_arr to s_scr.*
on key(f1,control-w)
prompt "Jump to: " for expr
let expr=expr clipped, "*"
open popcur using expr
fetch popcur into j
if status=0 then
call fgl_setcurrline(1,j)
else
error "menu item starting with ", expr, " not found."
end if
end display
end function
--popup.per
database formonly
screen size 24 by 80
{
++ Menu (Demo) ++
\g-----------------------------
[a ]
[a ]
[a ]
[a ]
[a ]
[a ]
[a ]
[a ]
[a ]
[a ]
[a ]
[a ]
[a ]
[a ]
[a ]
\g-----------------------------
}
attributes
a = formonly.tabname;
instructions
screen record s_scr [15] (tabname);
Regards,
Shriyan
"It is simple to make things complex, but complex to make things simple."