RPL Programming Examples 2-25
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:
"!
67!
Starts the outer conditional structure.
LS_#!
Returns the n objects in the list to levels 2
through (n + 1), and returns the list size n to
level 1.
452!Hd!DBM<!
Copies the list size and tests if it's 2.
:;<=!
4KL2!
67!
If the size is 2, moves the objects to level 1 and
2, and starts the inner conditional structure.
:P2<!cd!DBM<!
Tests if the object is a name: returns 1 if so,
otherwise 0.
DYB2!:P2<!cd!DBM<!
Moves the second object to level 1, then tests if
it is a name (returns 1 or 0).
B=4!
Combines test results: Returns 1 if both tests
were true, otherwise returns 0.
=L:!
:;<=!
IEtZp!G))(Z!psk!G$o)ZI
4L<KK!
<=4!
Reverses the final test result.
If the objects are not both names, displays an
error message and aborts execution.
Ends the inner conditional structure.
<ED<!
4KL2=!
I6uu)m$u!utZp!Zt})I!
4L<KK!
<=4!
If the list size is not 2, drops the list size,
displays an error message, and aborts
execution.
Ends the outer conditional.
1!
`ONAMES K
Stores the program in NAMES.
Checksum: # 10752d
Bytes: 141.5