Anonymous user
Menu: Difference between revisions
added PowerShell
(→{{header|Euphoria}}: Euphoria example added) |
(added PowerShell) |
||
Line 899:
Which is from the three pigs? 2
-> "huff and puff"</pre>
=={{header|PowerShell}}==
<lang powershell>function Get-Choice ([array] $Items) {
Set-StrictMode -Version Latest
do {
$Items | ForEach-Object { $i = 0 } { '{0,3}. {1}' -f (++$i),$_ }
$choice = Read-Host Your choice
} while ($choice -notmatch '^\d+$' -or
!(1..$Items.Length -eq $choice))
$Items[$choice-1]
}</lang>
Trying it out:
<lang powershell>Get-Choice 'fee fie', 'huff and puff', 'mirror mirror', 'tick tock'</lang>
<pre> 1. fee fie
2. huff and puff
3. mirror mirror
4. tick tock
Your choice: 0
1. fee fie
2. huff and puff
3. mirror mirror
4. tick tock
Your choice: 5
1. fee fie
2. huff and puff
3. mirror mirror
4. tick tock
Your choice: 2
huff and puff</pre>
=={{header|PureBasic}}==
|