Anonymous user
Menu: Difference between revisions
→{{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 BBC BASIC) |
(→{{header|REXX}}: added/changed comments, changed indentation, added DO-END comment labels, changed method of looping for user prompt, added an example of output. -- ~~~~) |
||
Line 1,223:
=={{header|REXX}}==
<lang rexx>/*REXX program shows a list, asks user for a selection number (integer).*/▼
▲/*REXX program shows a list, asks user for a selection number (integer).*/
do forever▼
call list_create /*create the list from scratch. */
call list_show /*display (show) the list to user*/
if
say right(' choose an item by entering a number from
parse pull x /*get the user's choice (if any).*/
▲ ok=1 /*assume everything is peachy. */
select
if x='' then call sayErr "a choice wasn't entered"▼
otherwise leave /*this leaves the DO FOREVER loop*/
end /*select*/
/*user might've entered 2. or 003*/
x=x/1 /*normalize the number (maybe). */
say; say 'you chose item' x": "
/*──────────────────────────────────LIST_CREATE─────────────────────────*/
list_create: #.1='fee
list.1='fee fie'▼
▲list.2='huff and puff'
▲list.3='mirror mirror'
#=4 /*store number of choices in #. */
▲list.4='tick tock'
▲list.0=4 /*store # of choices in list.0 */
return /*(above) is just one convention.*/
/*──────────────────────────────────LIST_SHOW───────────────────────────*/
list_show: say /*display a blank line. */
do j=1
say '
end /*j*/
say /*display another blank line. */
return
/*──────────────────────────────────SAYERR──────────────────────────────*/
'''output''' (up to the point of the prompt):
<pre style="overflow:scroll">
[item 2] huff and puff
[item 3] mirror mirror
[item 4] tick tock
════════════════════ choose an item by entering a number from 1 ───► 4
▲sayErr: if \ok then return; ok=0; say;say '***error!***' arg(1) x;say;say;return
</
=={{header|REBOL}}==
|