? Simple Menu Function ● SmileBASIC Source

Sign In

*Usernames are case-sensitive
Forgot my password
Space-Restriction Challenge QSP Phase Ends on March 26!

Simple Menu Function

A while ago, I wrote a simple menu function that I use all the time: DEF MENU(LIST$[]) VAR CHOICE%,SCROLL% VAR BTN%=#UP REPEAT IF BTN% AND #UP+#DOWN THEN IF BTN% AND #UP THEN DEC CHOICE% ELSEIF BTN% AND #DOWN THEN INC CHOICE% ENDIF CHOICE%=MIN(MAX(CHOICE%,0),LEN(LIST$)-1) SCROLL%=MIN(MAX(SCROLL%,CHOICE%-29),CHOICE%) CLS VAR ROW% FOR ROW%=0 TO MIN(30,LEN(LIST$))-1 LOCATE 1,ROW% PRINT LIST$[SCROLL%+ROW%]; NEXT LOCATE 0,CHOICE%-SCROLL% PRINT ""; ENDIF BTN%=BUTTON(1) VSYNC UNTIL BTN% AND #A CLS RETURN CHOICE% ENDUse the d-pad to move and A to select an item. The list scrolls if it's longer than 30 items. It can be used for a simple menu, file selection, etc. Example use: DIM FILELIST$[0] FILES "TXT",FILELIST$ VAR FILE$=FILELIST$[MENU(FILELIST$)] FILE$[0]="" 'remove * LOAD "PRG1:"+FILE$
2 votes
  • select
  • list
0 Comment(s)