RosettaCodeData/Task/Menu/Action-/menu.action

38 lines
642 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
DEFINE PTR="CARD"
BYTE FUNC Init(PTR ARRAY items)
items(0)="fee fie"
items(1)="huff and puff"
items(2)="mirror mirror"
items(3)="tick tock"
RETURN (4)
PROC ShowMenu(PTR ARRAY items BYTE count)
BYTE i
FOR i=1 TO count
DO
PrintF("(%B) %S%E",i,items(i-1))
OD
RETURN
BYTE FUNC GetMenuItem(PTR ARRAY items BYTE count)
BYTE res
DO
ShowMenu(items,count) PutE()
2025-02-27 18:35:13 -05:00
Print("Make your choice: ")
2023-07-01 11:58:00 -04:00
res=InputB()
UNTIL res>=1 AND res<=count
OD
RETURN (res-1)
PROC Main()
PTR ARRAY items(10)
BYTE count,res
count=Init(items)
res=GetMenuItem(items,count)
PrintF("You have chosen: %S%E",items(res))
RETURN