Menu: Difference between revisions
Content added Content deleted
Line 2,108: | Line 2,108: | ||
=={{header|PowerShell}}== |
=={{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> |
<lang PowerShell> |
||
function Select-TextItem |
function Select-TextItem |
||
Line 2,154: | Line 2,153: | ||
End |
End |
||
{ |
{ |
||
if(!$inputObject){ |
|||
return "" |
|||
} |
|||
do |
do |
||
{ |
{ |
||
Line 2,167: | Line 2,169: | ||
Write-Host ("{0,3}: {1}" -f 0,"To cancel") |
Write-Host ("{0,3}: {1}" -f 0,"To cancel") |
||
$choice = Read-Host $Prompt |
|||
$selectedValue = "" |
$selectedValue = "" |
||
Line 2,175: | Line 2,177: | ||
$selectedValue = $menuOptions[$choice - 1] |
$selectedValue = $menuOptions[$choice - 1] |
||
} |
} |
||
} |
} |
||
until ($choice -eq 0 -or $choice -le $menuOptions.Count) |
until ($choice -match "^[0-9]+$" -and ($choice -eq 0 -or $choice -le $menuOptions.Count)) |
||
return $selectedValue |
return $selectedValue |