hp40g+.book Page 18 Friday, December 9, 2005 1:03 AM

IF... THEN... ELSE...

END

CASE...END

IFERR...

THEN...

ELSE…

END...

Example

1XA : IF A==1

THEN MSGBOX " A EQUALS 1" : END:

Executes the true-clausesequence of commands if the test- clause is true, or the false-clausesequence of commands if the test-clauseis false.

IF test-clause

THEN true-clause ELSE false-clause END Example

1XA :

IF A==1 THEN

MSGBOX "A EQUALS 1" :

ELSE

MSGBOX "A IS NOT EQUAL TO 1" : A+1XA :

END:

Executes a series of test-clause commands that execute the appropriate true-clausesequence of commands. Its syntax is:

CASE

IF test-clause1THEN true-clause1END

IF test-clause2THEN true-clause2END

.

.

.

IF test-clausenTHEN true-clausenEND

END:

When CASE is executed, test-clause1is evaluated. If the test is true, true-clause1is executed, and execution skips to END. If test-clause1if false, execution proceeds to test- clause2. Execution with the CASE structure continues until a true-clause is executed (or until all the test-clauses evaluate to false).

Many conditions are automatically recognized by the HP 40gs as error conditions and are automatically treated as errors in programs.

21-18

 

 

Programming