2-26 RPL Programming Examples
NAMES is demonstrated in the program VFY.
VFY (Verify Program Argument)
VFY verifies that an argument on the stack is either a name or a list that contains exactly two names.
Level 1 " Level 1
'name'
"
'name'
{ valid list }
"
{ valid list }
{ invalid list }
"
{ invalid list } (and error message in status area)
invalid object
"
invalid object (and error message in status area)
Techniques used in VFY
! Utility programs. VFY by itself has little use. However, it can be used with minor modifications by other
programs to verify that specific object types are valid arguments.
! CASE…END (case structure). VFY uses a case structure to determine if the argument is a list or a name.
! Structured programming. If the argument is a list, VFY calls NAMES to verify that the list contains exactly
two names.
! Local variable structure. VFY stores its argument in a local variable so that it can be passed to NAMES if
necessary.
! Logical function. VFY uses NOT to display an error message.
Required Programs
NAMES
! NAMES (Check List for Exactly Two Names) verifies that a list argument contains exactly two names.
VFY program listing
Program: Comments:
"!
452!
Copies the original argument to leave on the
stack.
4:B>!
Removes any tags from the argument for
subsequent testing.
#!$jmo!
Stores the argument in local variable argm.
"!
OBD<!
$jmo!:P2<!Qd!DBM<!
:;<=!
$jmo!=BM<D!
<=4!
Begins the defining procedure.
Begins the case structure.
Tests if the argument is a list.
If so, puts the argument back on the stack and
calls NAMES to verify that the list is valid,
then leaves the CASE structure.