Case statements

Hey, anybody know how to use case statements, I knew how but I forgot and I think they would work very well for the program I am making for class. I would appreciate any help.


Hey dave

if it is for the yahtzee score system I'll show you how to set that up Tues when we get back to school.

If not and it is for something else you can look it up in the programming in true basic: problem solving with structure and style on pages 237,212,234,235, and 236. Or the TBBRONZE manual on pages 164,187, and 193. Or Let's Program it... in true basic on pages 100 and 101. or The discovery pak on page 09.9.

I personally find the Manual explains it the most.
Here is what the True Basic Manual says.

SELECT CASE select-expression
CASE case-specifier
. . .
CASE case-specifier
. . .
. . .
case-specifier:: case-part, …, case-part
case-part:: constant
constant TO constant
IS relational-operator constant

The SELECT CASE structure may have zero or more CASE parts, and zero or one CASE ELSE parts, but must have at least one of either a CASE or CASE ELSE part. The constants in a case-specifier must be of the same type (numeric or string) as the select-expression in
the SELECT CASE statement.

The select-expression in the SELECT CASE statement is first evaluated. The case-specifier in the first CASE part is then examined. If it satisfies any of the case-parts, then the statements following that CASE statement are executed and control passes to the first statement following END SELECT.

If no case-part in the first CASE statement is satisfied, then the second CASE statement is examined in a like manner, and so on. If no CASE statement is satisfied, then the statements following the CASE ELSE statement are executed. If no CASE statement is satisfied and there is no CASE ELSE part, then an
exception occurs.

If you would like I can e-mail you the .PDF version of the true basic Bronze manual.

I hope this helps. I think I got carried away.

Re: Case statements ...

Big Dave ... Google 'switch statements' and open the wikipedia article. "switch" and "case" are synonymous. Regards ... Tom M