See also: ABCUV, EGCD, IABCUV

IF

Type: Command Operation

Description: IF Conditional Structure Command: Starts IF … THEN … END and IF … THEN … ELSE … END conditional structures.

Conditional structures, used in combination with program tests, enable a program to make decisions.

IF … THEN … END executes a sequence of commands only if a test returns a nonzero (true) result. The syntax is:

IF testclause THEN trueclause END

IF begins the test clause, which must return a test result to the stack. THEN removes the test result from the stack. If the value is nonzero, the true clause is executed. Otherwise, program execution resumes following END.

IF … THEN … ELSE … END executes one sequence of commands if a test returns a true (nonzero) result, or another sequence of commands if that test returns a false (zero) result. The syntax is:

IF testclause THEN trueclause ELSE falseclause END

IF begins the test clause, which must return a test result to the stack. THEN removes the test result from the stack. If the value is nonzero, the true clause is executed. Otherwise, the false clause is executed. After the appropriate clause is executed, execution resumes following END.

In RPL mode, the test clause can be a command sequence (for example, A B ) or an algebraic (for example, 'A‰B'). If the test clause is an algebraic, it is automatically evaluated to a number (→NUM or EVAL isn’t necessary).

Access:

BRANCH IF

( °is the leftshift of the Nkey).

Input/Output:

 

 

 

 

 

 

 

 

 

 

 

Level 1/Argument 1

 

Level 1/Item 1

 

 

 

 

 

 

 

IF

 

 

 

THEN

T/F

 

 

END

 

 

 

 

IF

 

 

 

 

THEN

T/F

 

 

ELSE

 

 

 

END

 

 

CASE,

 

 

 

See also:

ELSE, END, IFERR, THEN

 

 

 

 

 

 

 

IFERR

Command

 

 

Type:

 

 

Description: If Error Conditional Structure Command: Starts IFERR … THEN … END and IFERR … THEN … ELSE … END error trapping structures.

Error trapping structures enable program execution to continue after a “trapped” error occurs.

IFERR … THEN … END executes a sequence of commands if an error occurs. The syntax of IFERR … THEN … END is:

IFERR trapclause THEN errorclause END

If an error occurs during execution of the trap clause: 1 The error is ignored.

2 The remainder of the trap clause is discarded.

3112 Full Command and Function Reference

Page 232
Image 232
HP 50g Graphing, 48gII Graphing manual Iferr, Case, ELSE, END, IFERR, then