HP 48gII Graphing Names Check List for Exactly Two Names, Techniques used in Names, `Onames K

Models: 50g Graphing 48gII Graphing

1 693
Download 693 pages 23.18 Kb
Page 105
Image 105

NAMES (Check List for Exactly Two Names)

If the argument for a program is a list (as determined by VFY), NAMES verifies that the list contains exactly two names. If the list does not contain exactly two names, an error message appears in the status area and program execution is aborted.

Level 1

Level 1

 

 

 

{ valid list }

 

{ invalid list }

(error message in status area)

 

 

 

Techniques used in NAMES

Nested conditionals. The outer conditional verifies that there are two objects in the list. If so, the inner conditional verifies that both objects are names.

Logical functions. NAMES uses the AND command in the inner conditional to determine if both objects are names, and the NOT command to display the error message if they are not both names.

NAMES program listing

Program:

Comments:

 

«

 

 

IF

Starts the outer conditional structure.

 

OBJ→

Returns the n objects in the list to levels

 

 

2 through (n + 1), and returns the list

 

 

size n to level 1.

 

DUP 2. SAME

Copies the list size and tests if it’s 2.

 

THEN

If the size is 2, moves the objects to

 

DROP

level 1 and 2, and starts the inner

 

IF

conditional structure.

 

TYPE 6. SAME

Tests if the object is a name: returns 1 if

 

 

so, otherwise 0.

 

SWAP TYPE 6. SAME

Moves the second object to level 1, then

 

 

tests if it is a name (returns 1 or 0).

 

AND

Combines test results: Returns 1 if both

 

 

tests were true, otherwise returns 0.

 

NOT

Reverses the final test result.

 

THEN

If the objects are not both names,

 

"List needs two names"

displays an error message and aborts

 

DOERR

execution.

 

END

Ends the inner conditional structure.

 

ELSE

If the list size is not 2, drops the list size,

 

DROPN

displays an error message, and aborts

 

"Illegal list size"

execution.

 

DOERR

 

 

END

Ends the outer conditional.

 

»

 

 

 

 

 

`ONAMES K

Stores the program in NAMES.

 

 

 

 

 

 

 

RPL Programming Examples 225

Page 105
Image 105
HP 48gII Graphing manual Names Check List for Exactly Two Names, Techniques used in Names, Names program listing, `Onames K