Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Main menu:

1 Delete
2 Create
3 Modify
4 Remove
X Exit

Submenu 1 (for Delete):

1 Delete file
2 Delete folder
3 Delete another file
4 Delete another folder
5 Back to Main Menu

Submenu 2 (for Create):

1 Create Virtual
2 Create another Virtual
3 Back to Main Menu

Submenu 3 (for Modify):

1 Modify Virtual
2 Modify another Virtual
3 Back to Main Menu

This is the main menu:

$q = Read-Host "
Please select an option:
1 Delete Files 
2 Create New Virtual
3 Modify Existing Virtual
"

Sub-Menu1

$su1 = Read-Host "
Please select an option
1 Delete a file
2 Delete a folder
3 Delete another file
4 Delete another folder
5 Back to main menu
"

How do I take option 5 and bring it back to the main menu?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
406 views
Welcome To Ask or Share your Answers For Others

1 Answer

You could create functions for each menu going through a switch so that you could keep calling new menus

function mainMenu(){
    clear
    switch(Read-Host "1 Delete
2 Create
3 Modify
4 Remove
X Exit"){
        X {break}
        2 {createMenu}
        default {"N/A"}
    }
}

function createMenu(){
    clear
    switch(Read-Host "Please select an option `
1 Delete a file
2 Delete a folder
3 Delete another file
4 Delete another folder
5 Back to main menu"){
        5 {mainMenu}
        default {"N/A"}
    }
}

mainMenu

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...