Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
45
Task/Menu/Icon/menu.icon
Normal file
45
Task/Menu/Icon/menu.icon
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
## menu.icn : rewrite of the faulty version on Rosetta Code site 24/4/2021
|
||||
|
||||
procedure main()
|
||||
|
||||
L := ["fee fie", "huff and puff", "mirror mirror", "tick tock"]
|
||||
K := ["hidie hi", "hidie ho", "mirror mirror on the Wall", "tick tock tick tok"]
|
||||
Z := []
|
||||
|
||||
choice := choose_from_menu(L) # call using menu L
|
||||
write("Returned value =", choice)
|
||||
choice := choose_from_menu(K) # call using menu K
|
||||
write("Returned value =", choice)
|
||||
choice := choose_from_menu(Z) # call using empty list
|
||||
write("Returned value =", choice)
|
||||
|
||||
|
||||
end ## of main
|
||||
# --------- subroutines below ---------------------------------
|
||||
|
||||
procedure choose_from_menu(X)
|
||||
|
||||
displaymenu(X)
|
||||
repeat {
|
||||
writes("Choose a number from the menu above: ")
|
||||
a := read()
|
||||
if a == "" then return(a) ## no selection
|
||||
|
||||
write("You selected ",a)
|
||||
if numeric(a) then {
|
||||
if integer(a) <= 0 | integer(a) > *X then displaymenu(X) else
|
||||
{ ## check entered option in range
|
||||
write(a, " ==> ",X[a])
|
||||
return ( string(a))
|
||||
}
|
||||
}
|
||||
else displaymenu(X)
|
||||
}
|
||||
|
||||
end ## choose_from_menu(X)
|
||||
|
||||
procedure displaymenu(X)
|
||||
every i := 1 to *X do
|
||||
write(i,") ",X[i]) ## dispay menu options
|
||||
|
||||
end ## displaymenu(X)
|
||||
Loading…
Add table
Add a link
Reference in a new issue