Thanks for the feedback. I still like this method for simple menus and I've written a simple menu front end for a program I'm currently working on. I've done several improvements. I know there are still some people who think this wastes memory and is slow. Here's my new version
Code: Select all
dim as string parameter(0 to 7) = {"","Off","On","PC","Off","9600"}
dim as integer x,y,button,v ,ov,baudrate,oldbaudrate,ts,oldts,dcolor
dim as integer xpos(7),ypos(7),bheight(7),bwidth(7)
dim as string text(0 to 7) = {"","Unique:","Count:","Time/Date:","Temp:","Baud:","Extra:","Start"}
dim as string baud(1 to 8) = {"1200","2400","4800","9600","19200","38400","57600","115200"}
dim as string timestamp(1 to 3) = {"Off","PC","Reader"}
ts=2
oldts=2
ov=0
baudrate=4
oldbaudrate=4
xpos(1)=100
ypos(1)=80
Screenres 190,400,8,2
Paint (160, 100), 30, 15
for x = 1 to 7
bheight(x)=30
bwidth(x)=150
xpos(x)=20
ypos(x)=(x*40)+40
' draw hidden buttons with unique color assignments
screenset 1,0
Line (xpos(x), ypos(x))-(xpos(x)+bwidth(x),ypos(x)+bheight(x)), x, bf
' draw visible buttons with same dimensions as hidden buttons
screenset 0,0
Line (xpos(x), ypos(x))-(xpos(x)+bwidth(x),ypos(x)+bheight(x)), 15, bf
Line (xpos(x)+2, ypos(x)+2)-(xpos(x)+bwidth(x)-2,ypos(x)+bheight(x)-2), 7, bf
draw string (xpos(x)+13,ypos(x)+10), text(x),1
draw string (xpos(x)+96,ypos(x)+10), parameter(x),0
next x
do
screenset 1,0
getmouse x,y,,button
if button <> 1 then
screenset 0,0
draw string (40,20), text(ov) & " pressed",30
select case as const ov
case 1,2,4
if parameter(ov)="OFF" then
draw string (xpos(ov)+96,ypos(ov)+10),parameter(OV),7
parameter(ov)="ON"
draw string (xpos(ov)+96,ypos(ov)+10),parameter(ov),2
else
draw string (xpos(ov)+96,ypos(ov)+10),parameter(ov),7
parameter(ov)="OFF"
draw string (xpos(ov)+96,ypos(ov)+10),parameter(ov),4
end if
case 3
ts=ts+1
if ts=4 then
ts=1
end if
if ts = 1 then
dcolor = 4
else
dcolor = 0
end if
draw string (xpos(ov)+96,ypos(ov)+10),timestamp(oldts),7
draw string (xpos(ov)+96,ypos(ov)+10),timestamp(ts),dcolor
oldts = ts
case 5
baudrate = baudrate +1
if baudrate = 9 then
baudrate = 1
end if
draw string (xpos(ov)+96,ypos(ov)+10),baud(oldbaudrate),7
draw string (xpos(ov)+96,ypos(ov)+10),baud(baudrate),0
oldbaudrate = baudrate
case 6
'to be defined
case 7
'code to start main program
end select
ov=0
screenset 1,0
end if
' get color of hidden screen at mouse coordinate
if button = 1 then
v=point(x,y)
screenset 0,0
if v <>0 then
draw string (40,20), text(v) & " pressed",1
ov=v
end if
end if
sleep 1,1
loop until inkey$<>""