RE: Help
Posted in 1996
--- On 27 Feb 1996 12:13:22 -0500 zabi <zabi.muc@sni.de> wrote:
>
>To all
>
>Hi,
>What version of informix 4GL can help in creating POP-UP menus ?.
>Is there any direct way ?.
>Help
>
>Zabiullah S.S
>
>Email :- zabi.muc@sni.de
Included find 4glWorks (my application framework) approach to pull down
menus. Watch out for bugs & unneeded code: I stripped 4glWorks unrelated code on the spot!
usage:
call mnv_start(help_no, col) #start menu, set help number &
#column where menu shows
call mnv_put("Item 1", "I", 1) #put items
call mnv_put("iTem 2", "", 2) #if snd parm null, first cap. is key to hit
....
call mnv_get() returning opt #get item
case
when opt is null #interrupt!
when opt=1
...
end case
BTW: sorry for posting code, but I don't have any URL to give away!
------ cut here: IFMNVL.4gl ----
# IFMNVL.4gl - Vertical menu routines
globals "varl.4gl"
define
lastcol,
maxwidth,
maxlines,
help_msg smallint,
p_mnv array[50] of record
desc_mnv char(25),
quickkey char(1),
msg smallint,
ambigue integer
end record
#
# vertical menu initialization
#
function mnv_start(hm, col)
define hm,
col smallint
whenever error call trap_err
let maxlines=0
let maxwidth=0
let help_msg=hm
let lastcol=col
end function
#
# insert item in vertical menu
#
function mnv_put(dm, qk, m)
define dm char(25),
qk char(1),
m smallint,
i smallint
let maxlines=maxlines+1
let p_mnv[maxlines].desc_mnv=dm
let p_mnv[maxlines].quickkey=qk
let p_mnv[maxlines].msg=m
let p_mnv[maxlines].parm=p
let p_mnv[maxlines].ambigue=false
if length(dm)>maxwidth
then
let maxwidth=length(dm)
end if
let i=1
while (i<maxlines)
if (p_mnv[i].quickkey=qk)
then
let p_mnv[i].ambigue=true
let p_mnv[maxlines].ambigue=true
end if
let i=i+1
end while
end function
#
# find ShortCut key
#function getfirstkey(dm)
define dm char(25),
i smallint
let i=1
while i<26
if ((dm[i]>="A") and (dm[i]<="Z")) or
((dm[i]>="0") and (dm[i]<="9"))
then
return dm[i]
end if
let i=i+1
end while
return ""
end function
#
# menu display & option selection
#
function mnv_get()
define i, j, k, l smallint,
linenum,
oldline,
firstline,
pglen,
rdwop smallint,
getit integer,
keyhit char(1)
let int_flag=false
let linenum=1
let firstline=0
case maxlines
when 0
error "No options!"
return ""
when 1
return p_mnv[1].msg
end case
let maxwidth=maxwidth+2
case
when lastcol<3
let lastcol=3
when lastcol>80-maxwidth
let lastcol=80-maxwidth
end case
if (maxlines>19)
then
let pglen=19
else
let pglen=maxlines
end if
open window mnv_win at 4, lastcol with pglen rows, maxwidth columns
attribute (border, form line first, comment line last,
prompt line last, message line last)
let rdwop=1
let getit=true
while getit
case
when rdwop!=0
let l=1
let j=firstline+pglen
if (j>maxlines)
then
let j=maxlines
end if
for k=firstline+1 to j
if (k!=linenum)
then
display " ", p_mnv[k].desc_mnv
at l, 1 attribute (normal)
else
display " ", p_mnv[k].desc_mnv at l, 1
attribute (reverse)
end if
let l=l+1
end for
if (rdwop<0)
then
for k=l to pglen
display "" at k, 1 attribute (normal)
end for
end if
when (oldline!=linenum)
if (oldline>0)
then
let l=oldline-firstline
display " ", p_mnv[oldline].desc_mnv
at l, 1 attribute (normal)
end if
let l=linenum-firstline
display " ", p_mnv[linenum].desc_mnv at l, 1
attribute (reverse)
end case
let rdwop=0
let oldline=linenum
let l=linenum-firstline
display "" at l, maxwidth
let keyhit=readkey()
let i=fgl_lastkey()
case
when int_flag
let getit=false
when i=fgl_keyval("help")
call showhelp(help_msg)
#
# beware!: very strange behaviour if help_msg points to a
# non existent help message
#
let int_flag=false
when i=13
let getit=false
when i=fgl_keyval("nextpage")
case
when (linenum+pglen-1<maxlines)
let linenum=linenum+pglen-1
let firstline=firstline+pglen-1
let rdwop=-1
when (firstline+pglen-1<maxlines)
let linenum=maxlines
let firstline=firstline+pglen-1
let rdwop=-1
when (linenum<maxlines)
let linenum=maxlines
end case
when i=fgl_keyval("prevpage")
case
when (firstline>=pglen-1)
let linenum=linenum-pglen+1
let firstline=firstline-pglen+1
let rdwop=1
when (firstline>0) and (linenum>pglen-1)
let firstline=0
let linenum=linenum-pglen+1
let rdwop=-1
when (firstline>0)
let firstline=0
let linenum=1
let rdwop=-1
when (linenum>1)
let linenum=1
end case
when i=fgl_keyval("F1")
case
when (linenum=1)
when (firstline=0)
let linenum=1
otherwise
let linenum=1
let firstline=0
let rdwop=-1
end case
when i=fgl_keyval("up")
case
when (linenum-firstline>1)
let linenum=linenum-1
when (linenum>1)
let rdwop=-1
let linenum=linenum-1
let firstline=firstline-1
otherwise
case
when (linenum>=maxlines)
when (linenum-firstline<pglen) and
(maxlines-firstline<=pglen)
let linenum=maxlines
otherwise
let linenum=maxlines
let firstline=linenum-pglen
let rdwop=-1
end case
end case
when i=fgl_keyval("down") or (i=32)
case
when (linenum>=maxlines)
case
when (linenum=1)
when (firstline=0)
let linenum=1
otherwise
let linenum=1
let firstline=0
let rdwop=-1
end case
when (linenum-firstline<pglen)
let linenum=linenum+1
otherwise
let rdwop=-1
let linenum=linenum+1
let firstline=firstline+1
end case
when i=fgl_keyval("F4")
case
when (linenum>=maxlines)
when (linenum-firstline<pglen) and (maxlines-firstline<=pglen)
let linenum=maxlines
otherwise
let linenum=maxlines
let firstline=linenum-pglen
let rdwop=-1
end case
when keyhit is null@@NL@