K
K
Kirill Ponomarev2016-05-31 17:51:24
PowerShell
Kirill Ponomarev, 2016-05-31 17:51:24

How do I go to the previous menu?

Hello. Help the ignoramus. I need to implement a goto replacement, but I can't figure out how to do it through do
. I have this structure


do {
Write-Host "1."
Write Host "2."
Write Host "3."
Write Host "4."
Write Host "5."
Write-Host "0.Exit"
Write-host
$choice1 = Read-Host "Select menu item"
do {
Switch ($choice_1){
1{
Write-Host "1."
Write Host "2."
Write-Host "0. Previous menu"

How to implement a return to the initial choice_1 menu here
With such a construction, it turns out to call the choice_2 menu on repeat, but it doesn’t work to go to choice_1.
Tell me what to do, maybe I stuffed too much.
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily, 2016-05-31
@jerichoussr

better without the GOTO ideology,
but if not then:
there are such replacements
if you need to skip part of the actions in the nested loop from below, enter a variable and a sheet from IF
if you make a jump to the beginning of the loop then continue
if you need to go up one level of the loop then break
if there are more levels then you need to use break label
and multi-level menus are better implemented through a function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question