[Tutor] Menu to choose programlets: if only python had a GoTO statement ;-))))

Ron Stephens rdsteph@earthlink.net
Thu, 12 Apr 2001 13:58:41 -0400


Sacrilege, I know. ;-))) But sometimesIi wonder why no modern language
will let me have a simple goto statement when nothing else will do as
well...this is a rhetorical statement only...

I have written and am writing a series of similar small programs to help
a user choose amongst several different alternatives. The programs
mostly use simple weighted averages based on several appropriate
criteria with weights, or importance levels. Maybe later, Bayes;-)))

On such program is general in nature and lets the user input the options
to be decided amongst, and then input the criteria to be used to decide
and then the weights for each criteria and then the scores for each
option on each criteria. Other options are sort of mini expert systems
in which the programmer pre inputs the options and criteria and the
scores for each option on each criteria, then the user only enters his
individual weights amongst the criteria. These programlets can cover any
field in which the programmer is "expert".

Now, my problem. I want to create a sort of simple menu to offer the
user a choice between the various mini-decisonanalysis programs. So, the
user can choose the general program, or else a specific program. Once
the user chooses, the appropriate mini-progran should launch.

If I had goto statements available, my job would be finished. Just
create a simple choice, say 1-10 and when the user inputs 10 the program
launches its program.

I first considered using a Tkinter menu, but I am still struggling with
gui event-driven programs. Also, if I use Tkinter, how would I solve my
basic problem to jump to each a specific program when the user chooses
its menu item? In other words, I would have to launch a procedural
program from a gui event-driven menu program.

So, now  I consider procedural menu program using raw_input. Still, how
do I go to the appropriate sub-program when the user chooses one? With
goto's this would be trivial. Now, I consider a nested set of "if "
statements that determines which number was chosen, but still how do I
"jump" to the correct sub-program??? Even if I define the subprograms as
functions even, how do I jump to them???

Any help for hopelessly confused newbie will be greatly appreciated...

Ron Stephens