Re: Menu programming (585 Views)
Reply
Honored Contributor
Oviwan
Posts: 692
Registered: ‎11-29-2005
Message 1 of 17 (585 Views)
Accepted Solution

Menu programming

Hi @ll,

what is the best way to programm a menu like the SAM. in which language is SAM programmed?

I prefer Perl or KSH. exists in Perl a module for a menu.

I saw in KSH exist something like:

select what in "Point1" "Point2"; do
case $REPLY in
1)
echo "foo bar"
break
;;
2)
echo "foo bar 1"
break
;;
esac
done

but exist something who looks more professional than that?

Thanks & Regards



Honored Contributor
Luk Vandenbussche
Posts: 2,734
Registered: ‎01-04-2000
Message 2 of 17 (585 Views)

Re: Menu programming

Hi,

If you add a new in SAM, it is shell script based.
Honored Contributor
Oviwan
Posts: 692
Registered: ‎11-29-2005
Message 3 of 17 (585 Views)

Re: Menu programming

Exist somewhere an example script that i can adapt to my rules?
Honored Contributor
Laurent Menase
Posts: 1,079
Registered: ‎11-06-2003
Message 4 of 17 (585 Views)

Re: Menu programming

Hi Try /usr/dt/bin/dtksh
examples are in /usr/dt/examples/dtksh
Honored Contributor
Laurent Menase
Posts: 1,079
Registered: ‎11-06-2003
Message 5 of 17 (585 Views)

Re: Menu programming

Or do you mean a curses oriented menu?
Honored Contributor
Laurent Menase
Posts: 1,079
Registered: ‎11-06-2003
Message 6 of 17 (585 Views)

Re: Menu programming

For Sam I believe, it is mainly in C, only a few parts are scripts.
it uses a undocumented library called libObam which does curses or X11 depending if DISPLAY is defined. In any case it is not usable
Honored Contributor
Geoff Wild
Posts: 7,170
Registered: ‎06-04-2001
Message 7 of 17 (585 Views)

Re: Menu programming

Here's a text based one I use - shell based - this one is called lp.mnu:

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Honored Contributor
Oviwan
Posts: 692
Registered: ‎11-29-2005
Message 8 of 17 (585 Views)

Re: Menu programming

Thanks @ll

@Geoff: that's what I searched

the dtksh is also nice, but i need a textbased menu. I found this thread for dtksh:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=101310

has someone an idea whether exists also something in perl?

Regards
Honored Contributor
Muthukumar_5
Posts: 4,030
Registered: ‎06-09-2004
Message 9 of 17 (585 Views)

Re: Menu programming

default perl is not having switch case statement as like shell prompt. If you want text based on terminal then you can go with case;do done statements itself.

-Muthu
Easy to suggest when don't know about the problem!
Honored Contributor
Arunvijai_4
Posts: 4,194
Registered: ‎04-07-2005
Message 10 of 17 (585 Views)

Re: Menu programming

You can use Perl with add-on modules to program menu driven apps. Check www.cpan.org for more information

http://search.cpan.org/~corliss/CursesWidgets-1.997/Widgets/Menu.pm

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Esteemed Contributor
Arturo Galbiati
Posts: 830
Registered: ‎02-10-2003
Message 11 of 17 (585 Views)

Re: Menu programming

Hi,
if you are interested I use a menu driveen created by awk. It's a general purpuose: you write in a file the line you want to see in teh menu and the associated command and nothing else.
Let me know if you want it and I'll attach.
(I'd like to avoid to attach unuseful scripts)

HTH,
Art
Honored Contributor
Laurent Menase
Posts: 1,079
Registered: ‎11-06-2003
Message 12 of 17 (585 Views)

Re: Menu programming

An example of what we can do in ksh
Honored Contributor
Oviwan
Posts: 692
Registered: ‎11-29-2005
Message 13 of 17 (585 Views)

Re: Menu programming

Thanks again @ll

@Art: it would be nice if you could attache the awk script, thx

Honored Contributor
Arunvijai_4
Posts: 4,194
Registered: ‎04-07-2005
Message 14 of 17 (585 Views)

Re: Menu programming

Here is an example using AWK,

http://www.iiug.org/software/archive/dbamenu
http://www.gnu.org/software/gawk/manual/gawkinet/gawkinet.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Esteemed Contributor
Arturo Galbiati
Posts: 830
Registered: ‎02-10-2003
Message 15 of 17 (585 Views)

Re: Menu programming

In the zip file there are the script and and example of the use.
The script to run is Menu.ksh.
HTH,
Art
Honored Contributor
Laurent Menase
Posts: 1,079
Registered: ‎11-06-2003
Message 16 of 17 (585 Views)

Re: Menu programming

Hi All,

Just a remark,

if you press space it toggles the line.
If you want to suppress that feature just comment the " ") case in the switch.
I saw too that the "tput cnorm" is not the right value to clear the bold mode, It is better to use "tput sgr0" to clear all the atributes at its place.

Also, the trick used it to set the non canonical mode with a timeout of (200ms) time=2 and min=1 (at least a charactere).
Sometimes it doesn't work as expected, so raise min to 3.
stty -icanon -echo min 3 time 2 ;
This will wait for 3 characteres or a inter timeout of 200ms
Honored Contributor
Rodney Hills
Posts: 1,679
Registered: ‎09-09-1996
Message 17 of 17 (585 Views)

Re: Menu programming

You could check out the "keysh" shell. It is somewhat programmable. Though it doesn't present a menu, it does use function keys to select tasks. Do a "man keysh" for more info.

Rod Hills
There be dragons...
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.