Board Thread:Questions and Answers/@comment-64.134.221.78-20150212054200/@comment-24006222-20150224164407

There is a way to use something equivalent to a SELECT ... CASE statement structure in Petit Computer. Way cool, and I have used it where appropriate. You can GOTO and GOSUB to a _Text_String_ !! Yes, you can say,

A=2

A$="@LABEL"+STR$(A)

GOTO A$

@LABEL1

@LABEL2

@LABEL3

In my program COOKTMR1 there's a subprogram called "@LTRUP" where I send a single character in, with X & Y coordinates, and the subprogram throws a big letter version of it on the screen. It goes:

GOTO "@UP"+LT$

then there are labels:

@UP1

@UP2

@UP3

and so on. So there's your SELECT ... CASE condition. If this was C, it would probably go (sorry I'm a bit rusty on this):

SELECT LT$

CASE 1

CASE 2

CASE 3

and so on. And the GOSUB version of this is awesome too. Watch out, it's easy to get a program error if you don't account for _all_ possible cases, and then when your program tries to go to a label that doesn't exist (like "@UP:" - colon), * BOOM * it smiles and crashes.