RosettaCodeData/Task/Menu/00DESCRIPTION

19 lines
854 B
Text
Raw Permalink Normal View History

2016-12-05 22:15:40 +01:00
;Task:
2015-11-18 06:14:39 +00:00
Given a prompt and a list containing a number of strings of which one is to be selected, create a function that:
2013-04-10 21:29:02 -07:00
2015-11-18 06:14:39 +00:00
* prints a textual menu formatted as an index value followed by its corresponding string for each item in the list;
* prompts the user to enter a number;
* returns the string corresponding to the selected index number.
2013-04-10 21:29:02 -07:00
2016-12-05 22:15:40 +01:00
<br>
2015-11-18 06:14:39 +00:00
The function should reject input that is not an integer or is out of range by redisplaying the whole menu before asking again for a number. The function should return an empty string if called with an empty list.
2013-04-10 21:29:02 -07:00
2016-12-05 22:15:40 +01:00
For test purposes use the following four phrases in a list:
fee fie
huff and puff
mirror mirror
tick tock
2013-04-10 21:29:02 -07:00
2016-12-05 22:15:40 +01:00
;Note:
This task is fashioned after the action of the [http://www.softpanorama.org/Scripting/Shellorama/Control_structures/select_statements.shtml Bash select statement].