<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">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: &lt;1992May12.212414.8703@fnbc.com&gt;
#Keywords: menuing system
#Sender: news@fnbc.com
#Organization: First National Bank Of Chicago, Chicago IL, USA
#References: &lt;1992May11.144520.12956@visix.com&gt;
#Date: Tue, 12 May 92 21:24:14 GMT
#Lines: 96
#Status: OR
#
#In article &lt;1992May11.144520.12956@visix.com&gt; ken@visix.com (Ken Mayer)  
#writes:
#&gt; I've always wanted to see a combination of curseperl and some other
#&gt; library so you could create a general menuing 'system' Given some data
#&gt; structure; throw a menu up on the screen and return the selection.
#&gt; I've been too lazy to write one myself, and I keep thinking that
#&gt; 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";
	&amp;choose('e:Entering Data:&amp;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(&lt;STDIN&gt;);
	chop($trader);
	@rows = &amp;lookup($trader);
	&amp;printRows(*rows);

  	&amp;choose('r:Return to Top:TOP',
  	  	'q:Quit:QUIT');  
}
 
ALLOCATE:
{
        system "clear";
	print "Enter Ticket Number of Trade to Allocate\n";
	$ticket = scalar(&lt;STDIN&gt;);
	&amp;breakdown($ticket);
  	&amp;choose('r:Return to Top:TOP',
  	  	'q:Quit:QUIT');  
}

QUIT:{ &amp;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&gt;&gt; ";
	        local($answer) = scalar(&lt;STDIN&gt;);
		chop($answer);

		foreach $l (@list)
		{
			($num, $text, $func) = split(":",$l);
			if ($num eq $answer) 
			{
			    @funclist = split(";", $func);
			    foreach $f (@funclist)
			    { 
			        if ($f =~ /&amp;/ ) { 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."
#
#
</pre></body></html>