Menu: Difference between revisions

127 bytes removed ,  4 years ago
Line 2,108:
 
=={{header|PowerShell}}==
{{incorrect|PowerShell|The function should return an empty string if called with an empty list. Please also check if this could really used as a [https://en.wikipedia.org/wiki/Subroutine function aka subroutine].}}
<lang PowerShell>
function Select-TextItem
Line 2,154 ⟶ 2,153:
End
{
if(!$inputObject){
return ""
}
do
{
Line 2,167 ⟶ 2,169:
Write-Host ("{0,3}: {1}" -f 0,"To cancel")
 
[int]$choice = Read-Host $Prompt
 
$selectedValue = ""
Line 2,175 ⟶ 2,177:
$selectedValue = $menuOptions[$choice - 1]
}
 
}
until ($choice -match "^[0-9]+$" -and ($choice -eq 0 -or $choice -le $menuOptions.Count))
 
return $selectedValue
Anonymous user