Programming Dilema

How can I design a program in which the answer I type determines which subroutine it does next? It's killing me, I've been trying for weeks!
Can someone please help me!

Comments

Re: Programming dilema

billygoat16 ... It's likely you can write your program using just 1 subroutine, or even no subroutine at all. Regards ... Tom M

Dilema

Hi,

I would gues that you have a relatively small finite number of sub-routines. Let us assume they are called:
SUB one
SUB two
SUB three
etc

Firstly get some user input e.g.
INPUT PROMPT "Type the routine name=":answer$
LET answer$=lcase$(answer$) ! makes sure it is lower case
DO
SELECT CASE answer$
CASE "one"
CALL one
EXIT DO
CASE "two"
CALL two
EXIT DO
CASE "three"
CALL three
EXIT DO
CASE ELSE
PRINT "Answer not recognized."
END SELECT
LOOP

Regards
Big John

Re: Programming Dilema ...

billygoat16 ... There's more than one way to address your programming problem. What I would do is to install all of your acceptable answers into a single string variable, named good_ans$.

Then, when you type your answer, you put that answer into another string variable, named my_ans$.

Then you search for my_ans$ in good_ans$. There are several simple ways to do that search. In essence, you slide my_ans$ along good_ans$ step by step, looking for a pattern match. If and when you find a match, you will be able to CALL the subroutine appropriate for your typed-in answer. Regards ... Tom M