# ------------------------ # ----====[ MAIN ]====---- # ------------------------ gosub :startmenu halt #---------------------------------------------- # ----====[ BEGINNING OF MENU SECTION ]====---- #---------------------------------------------- :startmenu echo "*At startmenu*" # This simply checks to see if there was already a menu_setup.txt file that saved the # previous state of the menu. if there is, it loads those values, if not, it assumes # the default menu values. fileexists $setupfile "Menu_setup.txt" if $setupfile = FALSE goto :getmenuinfo else read "Menu_setup.txt" $menu_optionA 1 read "Menu_setup.txt" $menu_optionB 2 read "Menu_setup.txt" $menu_optionC 3 read "Menu_setup.txt" $menu_optionDsubA 4 read "Menu_setup.txt" $menu_optionDsubB 5 goto :createmenu end :getmenuinfo # ====[ Initialize Starting Variables ]==== # If there is no menu_setup.txt file, this is where the default menu values are stored. # The ====[Set the menu values]==== section is where they are actually set. setvar $menu_optionA "y" setvar $menu_optionB 1234 setvar $menu_optionC "y" setvar $menu_optionDsubA "y" setvar $menu_optionDsubB 1234 goto :createmenu # ====[ Create the Menu]==== # Here is where the menus are actually created. # Notice how each menu item is named, and associated with it's parent menu. :createmenu addMenu "" "mainmenu" "Menu Title Here" "." "" "Main Menu" FALSE addMenu "mainmenu" "Execute" "Start Script" "Z" :Menu_Exec "" TRUE addMenu "mainmenu" "Option_A_Name" "What do you want? " "A" :Menu_option_A "" FALSE addMenu "mainmenu" "Option_B_Name" "What do you want? " "B" :Menu_option_B "" FALSE addMenu "mainmenu" "Option_C_Name" "What do you want? " "C" :Menu_option_C "" FALSE # NOTE: when calling sub-meus, you don't put in a script lable for it to reference # It just opens up the menu automatically. addMenu "mainmenu" "Option_D_Sub_Name" "Open sub menu D " "D" "" "" FALSE # these are the submenu entries for option D addMenu "Option_D_Sub_Name" "Option_D_subA" "What do you want?" "A" :Menu_option_D_Sub_A "" FALSE addMenu "Option_D_Sub_Name" "Option_D_subB" "What do you want?" "B" :Menu_option_D_Sub_B "" FALSE addMenu "Option_D_Sub_Name" "Option_D_subZ" "Back to main menu" "Z" :Menu_option_D_Sub_Z "" FALSE # ====[ Set the menu values ]==== # Here is where the menu values are actually set. I use variables to set them, # But you could simply use numbers or text if you wanted. I use variables, since # I save the menu state each time, so I can write them to a file. setmenuvalue "Option_A_Name" $menu_optionA setmenuvalue "Option_B_Name" $menu_optionB setmenuvalue "Option_C_Name" $menu_optionC setmenuvalue "Option_D_subA" $menu_optionDsubA setmenuvalue "Option_D_subB" $menu_optionDsubB # ====[ Set the menu options ]==== # Here is where I set the menu optons. # The first option allows for the Exit menu option. # The second option allows for hitting ? to get a list of commands. # (I usually don't bother with this one, so I leave it false cause it saves one line) # The third option allows for help on an entry. Not needed if you don't include help. # (I always include help, so I always leave it on) setmenuoptions "mainmenu" TRUE FALSE TRUE # setmenuoptions "Option_D_Sub_Name" TRUE FALSE TRUE # ====[ Set the menu HELP ]==== # Here is where you set the help for each menu. Note how it uses the Menu Name to # Reference each item. setmenuhelp "mainmenu" "This menu configures Script Settings." setmenuhelp "Execute" "This starts the script!" setmenuhelp "Option_A_Name" "This tells the script to do whatever for option A" setmenuhelp "Option_B_Name" "This tells the script to do whatever for option B" setmenuhelp "Option_C_Name" "This tells the script to do whatever for option C" setmenuhelp "Option_D_Sub_Name" "This opens up the D submenu" setmenuhelp "Option_D_subA" "This tells the script to do whatever for option D sub A" setmenuhelp "Option_D_subB" "This tells the script to do whatever for option D sub B" # ====[ Open the menu ]==== # this actually activates the menu. # The echo statement below does a clearscreen. makes it look pretty. echo "****" openMenu "mainmenu" #----====[ Menu_exec, when you press "Z", you go here ]====---- # This option closes the menu, and puts executes the rest of the script # This is also where the menu settings get saved for the next time. :Menu_Exec # closeMenu delete "Menu_setup.txt" write "Menu_setup.txt" $menu_optionA write "Menu_setup.txt" $menu_optionB write "Menu_setup.txt" $menu_optionC write "Menu_setup.txt" $menu_optionDsubA write "Menu_setup.txt" $menu_optionDsubB return # ====[ Menu_Option_A, when you press "A", you go here ]==== # This is a simple y/n toggle :Menu_option_A if $menu_optionA = "y" setvar $menu_optionA "n" setmenuvalue "Option_A_Name" $menu_optionA echo "****" openmenu "mainmenu" else setvar $menu_optionA "y" setmenuvalue "Option_A_Name" $menu_optionA echo "****" openmenu "mainmenu" end # ====[ Menu_option_B, when you press "B", you go here ]==== :Menu_option_B # This asks the user for input, like a sector number or whatever # Checks to see if the value entered is a number. getinput $menu_optionB "Text for Menu Option B goes here: " isNumber $test_menu_optionB $menu_optionB if ($test_menu_optionB = 0) echo ANSI_12 "**Must be a number!*" ANSI_15 goto :Menu_option_B end setmenuvalue "Option_B_Name" $menu_optionB echo "****" openmenu "mainmenu" # ====[ Menu_option_C, when you press "C", you go here ]==== # This is another toggle menu :Menu_option_C if $menu_optionC = "y" setvar $menu_optionC "n" setmenuvalue "Option_C_Name" $menu_optionC echo "****" openmenu "mainmenu" else setvar $menu_optionC "y" setmenuvalue "Option_C_Name" $menu_optionC echo "****" openmenu "mainmenu" end # ====[ Menu_option_D_Sub_A, when you press "A" from submenu D, you go here ]==== # Yet another simple toggle :Menu_option_D_Sub_A if $menu_optionDsubA = "y" setvar $menu_optionDsubA "n" setmenuvalue "Option_D_subA" $menu_optionDsubA echo "****" openmenu "Option_D_Sub_Name" else setvar $menu_optionDsubA "y" setmenuvalue "Option_D_subA" $menu_optionDsubA echo "****" openmenu "Option_D_Sub_Name" end # ====[ Menu_option_D_Sub_B, when you press "B" from submenu D, you go here ]==== # This just grabs whatever the user enters. :Menu_option_D_Sub_B getinput $menu_optionDsubA "Text for Menu Option D sub B goes here: " setmenuvalue "Option_D_SubB" $menu_optionDsubA echo "****" openmenu "Option_D_Sub_Name" # ====[ Menu_option_D_Sub_Z, when you press "Z" from submenu D, you go here ]==== :Menu_option_D_Sub_Z echo "****" openmenu "mainmenu" #---------------------------------------- # ----====[ END OF MENU SECTION ]====---- #----------------------------------------