Menu: Difference between revisions
Content deleted Content added
→{{header|REXX}}: added/changed comments, changed indentation, added DO-END comment labels, changed method of looping for user prompt, added an example of output. -- ~~~~ |
Added XPL0 |
||
Line 1,572: | Line 1,572: | ||
Which is from the three pigs: 2 |
Which is from the three pigs: 2 |
||
You chose: huff and puff</pre> |
You chose: huff and puff</pre> |
||
=={{header|XPL0}}== |
|||
<lang XPL0>include c:\cxpl\codes; |
|||
string 0; |
|||
func Menu(List); |
|||
int List; |
|||
int Size, I, C; |
|||
[Size:= List(0); |
|||
if Size < 1 then return List(0); |
|||
for I:= 1 to Size-1 do |
|||
[IntOut(0, I); Text(0, ": "); |
|||
Text(0, List(I)); CrLf(0); |
|||
]; |
|||
CrLf(0); |
|||
Text(0, List(Size)); \display prompt |
|||
loop [C:= ChIn(0); \buffered keyboard requires Enter key |
|||
if C>=^1 & C<=Size-1+^0 then return List(C-^0); |
|||
Text(0, "Please enter 1 thru "); IntOut(0, Size-1); |
|||
Text(0, ": "); |
|||
]; |
|||
]; |
|||
Text(0, Menu([5, "fee fie", "huff and puff", "mirror mirror", "tick tock", |
|||
"Which phrase is from the Three Little Pigs? "]))</lang> |
|||
Example output: |
|||
<pre> |
|||
1: fee fie |
|||
2: huff and puff |
|||
3: mirror mirror |
|||
4: tick tock |
|||
Which phrase is from the Three Little Pigs? 5 |
|||
Please enter 1 thru 4: 2 |
|||
huff and puff |
|||
</pre> |
|||
{{omit from|GUISS}} |
{{omit from|GUISS}} |