Menu: Difference between revisions

846 bytes added ,  11 years ago
Added BBC BASIC
(Added BBC BASIC)
Line 194:
sel$ = ret$
end function</lang>
 
=={{header|BBC BASIC}}==
<lang bbcbasic> DIM list$(4)
list$() = "fee fie", "huff and puff", "mirror mirror", "tick tock"
selected$ = FNmenu(list$(), "Please make a selection: ")
PRINT selected$
END
DEF FNmenu(list$(), prompt$)
LOCAL index%, select$
IF SUM(list$()) = "" THEN = ""
REPEAT
CLS
FOR index% = 0 TO DIM(list$() ,1)
IF list$(index%)<>"" PRINT ; index% ":", list$(index%)
NEXT
PRINT prompt$ ;
INPUT "" select$
index% = VAL(select$)
IF select$<>STR$(index%) index% = -1
IF index%>=0 IF index%<=DIM(list$() ,1) IF list$(index%)="" index% = -1
UNTIL index%>=0 AND index%<=DIM(list$(), 1)
= list$(index%)</lang>
Empty entries in the list are not offered as options, nor accepted as a selection.
 
=={{header|Brat}}==