eval 'exec /bin/perl -S $0 ${1+"$@"}' if 0; #Newsgroups: comp.lang.perl #Path: lightnin!sdf!adaptex!egsner!convex!darwin.sura.net!europa.asd.contel.com!uunet!psinntp!juliet!news #From: jja@amy (Joseph Alotta) #Subject: Re: a menuing system in perl #Message-ID: <1992May12.212414.8703@fnbc.com> #Keywords: menuing system #Sender: news@fnbc.com #Organization: First National Bank Of Chicago, Chicago IL, USA #References: <1992May11.144520.12956@visix.com> #Date: Tue, 12 May 92 21:24:14 GMT #Lines: 96 #Status: OR # #In article <1992May11.144520.12956@visix.com> ken@visix.com (Ken Mayer) #writes: #> I've always wanted to see a combination of curseperl and some other #> library so you could create a general menuing 'system' Given some data #> structure; throw a menu up on the screen and return the selection. #> I've been too lazy to write one myself, and I keep thinking that #> someone somewhere must have done this before. # #I am writing something now. Here's a test program that implements the #menuing scheme. Don't tell anyone, ..... but... it uses...gasp..gotos. # TOP: { system "clear"; print "Welcome to VAL-trade, the VALue-added trading system\n\n"; &choose('e:Entering Data:&p("function not implemented");TOP', 'l:list trades to be allocated:LIST', 'a:allocate a trade:ALLOCATE', 'q:Quit:QUIT' ); } LIST: { system "clear"; print "Enter Trader ID:\n"; $trader = scalar(); chop($trader); @rows = &lookup($trader); &printRows(*rows); &choose('r:Return to Top:TOP', 'q:Quit:QUIT'); } ALLOCATE: { system "clear"; print "Enter Ticket Number of Trade to Allocate\n"; $ticket = scalar(); &breakdown($ticket); &choose('r:Return to Top:TOP', 'q:Quit:QUIT'); } QUIT:{ &p("Thank You for using our humble little system"); system "clear"; } sub p { local($x) = @_; print "$x\n"; sleep 1; } sub choose { local(@list) = @_; local($i, $l, $f, $func, $num, $test, $answer, @funclist); SCAN: { foreach $l (@list) { ($num, $text, $func) = split(":",$l); print "$num : $text\n"; } print "\n>> "; local($answer) = scalar(); chop($answer); foreach $l (@list) { ($num, $text, $func) = split(":",$l); if ($num eq $answer) { @funclist = split(";", $func); foreach $f (@funclist) { if ($f =~ /&/ ) { eval("$f"); } else { eval("goto $f"); } } } } print "\nChoose one of the following:\n"; redo SCAN; } } # #-- #Joe Alotta #First Chicago Corp. #jja@fnbc.com #(312)732-3439 # #"Wisdom is better than gold and understanding more valuable than silver." # #