Page 1 of 1
simple menu
Posted: Mon Jun 16, 2008 12:57 am
by stilgar
hey all,
I am having trouble remembering how to make a simple 1 colum scroll menu for 5 items. i remember it used menuitem command, but not remeber any more.
I also remeber that it highlighted the item as you used the up/down buttons to scroll. then hit return to select the item.
thanks
Posted: Tue Jun 17, 2008 2:37 pm
by pebe
Posted: Wed Jun 18, 2008 3:20 am
by stilgar
Thanks pebe.
I found my old menu code its a bit longer that the other, perhaps someone can use it.
Code...
Code: Select all
DIM MenuItem(6) AS STRING 'define the menu item array
DIM ChooseItem AS INTEGER ' currently chossen menu item
DIM XMenuPosn AS INTEGER 'controls menu x positions
DIM YMenuPosn AS INTEGER 'controls menu y position
Color 12: LOCATE 8,21: PRINT " Please press enter to select. " ' menu header
' menu items
MenuItem$(1) = " Load Invoice"
MenuItem$(2) = " New Client"
MenuItem$(3) = " Delete Client"
MenuItem$(4) = " Setup"
MenuItem$(5) = " Print Invoice"
MenuItem$(6) = " Exit"
ChooseItem = 1 'starts at the top
XMenuPosn = 28 'Horz
YMenuPosn = 10 'Vert
GOSUB DrawMenu
DO 'move hightlighted area up or down
Cmmnd$ = INKEY$
IF LEN(Cmmnd$) = 2 THEN Cmmnd$ = RIGHT$(Cmmnd$,1)
IF Cmmnd$ = "8" OR Cmmnd$ = CHR$(72) THEN GOSUB MoveUp
IF Cmmnd$ = "2" OR Cmmnd$ = CHR$(80) THEN GOSUB MoveDown
GOSUB DrawMenu
LOOP UNTIL Cmmnd$ = CHR$(13)
SOUND 1000,2
' what to do when enter is pressed
IF MenuItem(ChooseItem) = MenuItem$(1) THEN END: REM call loadinvoice
IF MenuItem(ChooseItem) = MenuItem$(2) THEN END: REM call newclient
IF MenuItem(ChooseItem) = MenuItem$(3) THEN END: REM call deleteclient
IF MenuItem(ChooseItem) = MenuItem$(4) THEN END: REM call setup
IF MenuItem(ChooseItem) = MenuItem$(5) THEN END: REM call printinvoice
IF MenuItem(ChooseItem) = MenuItem$(6) THEN SYSTEM 'exit
END
DrawMenu:
LOCATE YMenuPosn, XMenuPosn
FOR Count = 1 to UBOUND(MenuItem$)
IF Count = ChooseItem THEN COLOR 14 ELSE COLOR 8
PRINT MenuItem$(Count)
LOCATE CSRLIN, XMenuPosn
NEXT Count
RETURN
MoveUp:
SOUND 1000, 2
IF ChooseItem = 1 THEN
ChooseItem = UBOUND(MenuItem$)
ELSE
ChooseItem = ChooseItem - 1
END IF
RETURN
MoveDown:
SOUND 1000, 2
IF ChooseItem = UBOUND(MenuItem$) THEN
ChooseItem = 1
ELSE
ChooseItem = ChooseItem + 1
END IF
RETURN
Edit: Code tags added by admin