- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Menu scripts
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2001 12:23 PM
06-29-2001 12:23 PM
I have written some using if statements and some using the case statement. Does it matter as far as performance or is it just personal preference ?
Richard
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2001 12:30 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2001 12:50 PM
06-29-2001 12:50 PM
Re: Menu scripts
Performance in a menu is hardly an issue but clarity is. A long list of if's quickly gets messy but a case statement seldom does.
Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2001 01:48 PM
06-29-2001 01:48 PM
Re: Menu scripts
There's another very good reason for using 'case' statements in many languages (shell programs among them).
'case' statements can greatly simplify readability of complex blocks of code. Entire blocks of code, including other 'if' satements can easily be added under each case head (label). This greatly enhances the ability to augment a script over time with new features without making the script unreadable or untenable to enhance or further maintain.
In shell scripting, file-matching patterns can be used, something that can't be done with an 'if' statement. For example,
case `ls *.log` in
syslog.log )
...
esac
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2001 02:33 PM
06-29-2001 02:33 PM
Re: Menu scripts
PS3="/nChoose number:"
select ANS in new prev next edit exit quit
do
case $ANS in
new) print "New choice";;
prev) print "Go back";;
prev|next) print "edit things";;
exit|quit) break;;
*) print "Bad choice";;
esac
done
PS3 is the select prompt. Multiple columns are automatically formatted to fit within LINES and COLUMNS. select is repeated until the script hits a break, exit or return. TMOUT can be changed to perform a timeout.
Bill Hassell, sysadmin