Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Menu/Phix/menu.phix
Normal file
27
Task/Menu/Phix/menu.phix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
function menu_select(sequence items, object prompt)
|
||||
sequence res = ""
|
||||
items = remove_all("",items)
|
||||
if length(items)!=0 then
|
||||
while 1 do
|
||||
for i=1 to length(items) do
|
||||
printf(1,"%d) %s\n",{i,items[i]})
|
||||
end for
|
||||
puts(1,iff(atom(prompt)?"Choice?":prompt))
|
||||
res = scanf(trim(gets(0)),"%d")
|
||||
puts(1,"\n")
|
||||
if length(res)=1 then
|
||||
integer nres = res[1][1]
|
||||
if nres>0 and nres<=length(items) then
|
||||
res = items[nres]
|
||||
exit
|
||||
end if
|
||||
end if
|
||||
end while
|
||||
end if
|
||||
return res
|
||||
end function
|
||||
|
||||
constant items = {"fee fie", "huff and puff", "mirror mirror", "tick tock"}
|
||||
constant prompt = "Which is from the three pigs? "
|
||||
string res = menu_select(items,prompt)
|
||||
printf(1,"You chose %s.\n",{res})
|
||||
Loading…
Add table
Add a link
Reference in a new issue