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

38 lines
642 B
Plaintext

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()
Print("Make your choice: ")
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