You can use break to get out of a while loop without exiting the entire script.
Use function when you do some tasks many times.
By the way, here is a sample of your code with some little improvment
If we want to exit, there already is a choice in the menu, so .... the following lines are useless (and even bad for the workflow of query)
It's me again :)
I would like to create a script that will display a 'Main Menu' which will link to other scripts in the same directory. Is it possible to have a scrolling menu and pretty colours for this? :) (9 Replies)
I'm working on a script for a basic menu with four options. The first option for the menu asks a user to put in anyone's user name and is supposed to display the user's home directory. If a user does not enter a name, then their own home directory should be displayed. The second menu option is... (0 Replies)
So, I need help writing a Menu script in UNIX.
First how can I use letters for the options instead of numbers?
Also, is there any templates out on the web I can use? (2 Replies)
The code im having problems with is highlighted in red, upon selecting option 2 on the main menu (highlighted green) my echo "NETWORK CONNECTIVITY" command seems to get overlooked and the resulting output is "Thank you for using the Operator Administrative Tool." being displayed. Can anyone tell me... (2 Replies)
Hi,
I need to have a shell script for the below need.
1. Menu with one heading and 4 options.
2. the heading and 4 options are taken from a file.
File entry
======
Heading1|option1|option2|option3|option4|
Heading2|option1|option2|option3|option4|
3. the user entries must be captured in... (9 Replies)
Hi!
I have created on script which is working fine with menu options and with a sub-menu.
I want to enhance it by using sub-options under menu options.
Like.
option 1) will give the list only.
option 1.1) should give the option to user to choose one file, whose content user wanna see. ... (3 Replies)
hi all i am a newbie to this
is there any examples on creating a main menu with 3 sub menu
main menu -> option a , b and c
a menu -> option 1 ,2 and 3
b menu -> option 1 ,2
c menu -> option 1 ,2
i am getting headache as my code kept getting unexpected EOF
---------- Post... (0 Replies)
I installed CentOS 8 with Gnome 3.28.2 and I noticed that the "switch user" menu item disappeared from under the system menu of Gnome classic (Both X11 & Wayland). I checked google and this problem seems to have a history going back several releases of Gnome.
Unfortunately, I never found a... (1 Reply)
Discussion started by: bodisha
1 Replies
LEARN ABOUT DEBIAN
curses::widgets::menu
Widgets::Menu(3pm) User Contributed Perl Documentation Widgets::Menu(3pm)NAME
Curses::Widgets::Menu - Menu Widgets
MODULE VERSION
$Id: Menu.pm,v 1.103 2002/11/14 01:26:34 corliss Exp corliss $
SYNOPSIS
use Curses::Widgets::Menu;
$menu = Curses::Widgets::Menu->new({
COLUMNS => 10,
INPUTFUNC => &scankey,
FOREGROUND => undef,
BACKGROUND => 'black',
FOCUSSWITCH => " ",
X => 1,
Y => 1,
MENUS => {
MENUORDER => [qw(File)],
File => {
ITEMORDER => [qw(Save Quit)],
Save => &Save,
Quit => &Quit,
},
CURSORPOS => 'File',
BORDER => 1,
});
$menu->draw($mwh, 1);
$menu->execute;
See the Curses::Widgets pod for other methods.
REQUIREMENTS
Curses
Curses::Widgets
Curses::Widgets::ListBox
DESCRIPTION
Curses::Widgets::Menu provides simplified OO access to menus. Each item in a menu can be tied to a subroutine reference which is called
when selected.
METHODS
new (inherited from Curses::Widgets)
$menu = Curses::Widgets::Menu->new({
INPUTFUNC => &scankey,
FOREGROUND => undef,
BACKGROUND => 'black',
FOCUSSWITCH => " ",
MENUS => {
MENUORDER => [qw(File)],
File => {
ITEMORDER => [qw(Save Quit)],
Save => &Save,
Quit => &Quit,
},
CURSORPOS => 'File',
BORDER => 1,
});
The new method instantiates a new Menu object. The only mandatory key/value pairs in the configuration hash are X and Y. All others have
the following defaults:
Key Default Description
============================================================
INPUTFUNC &scankey Function to use to scan for keystrokes
FOREGROUND undef Default foreground colour
BACKGROUND 'black' Default background colour
FOCUSSWITCH " " Characters which signify end of input
MENUS {} Menu structure
CURSORPOS '' Current position of the cursor
BORDER 0 Avoid window borders
The MENUS option is a hash of hashes, with each hash a separate menu, and the constituent hashes being a Entry/Function pairs. Each hash
requires a special key/value pair that determines the order of the items when displayed. Each item is separated by two spaces.
draw
$menu->draw($mwh, 1);
The draw method renders the menu in its current state. This requires a valid handle to a curses window in which it will render itself.
The optional second argument, if true, will cause the selection cursor to be rendered as well.
popup
$menu->popup;
This method causes the menu to be displayed. Since, theoretically, the menu should never be seen unless it's being actively used, we will
always assume that we need to draw a cursor on the list as well.
execute
$menu->execute;
This method acts like the standard Curses::Widgets method of the same name, with the exception being that selection of any menu item will
also cause it to exit (having already called the associated item subroutine).
HISTORY
2002/10/17 -- First implementation
AUTHOR /COPYRIGHT
(c) 2001 Arthur Corliss (corliss@digitalmages.com)
perl v5.8.8 2006-09-14 Widgets::Menu(3pm)