Checksum: # 10752d

Bytes: 141.5

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 verifies that a list argument contains exactly two names.

VFY program listing

Program:

Comments:

«

 

DUP

Copies the original argument to leave on

 

the stack.

DTAG

Removes any tags from the argument for

 

subsequent testing.

→ argm

Stores the argument in local variable argm.

«

Begins the defining procedure.

CASE

Begins the case structure.

argm TYPE 5. SAME

Tests if the argument is a list.

THEN

If so, puts the argument back on the stack

argm NAMES

and calls NAMES to verify that the list is

END

valid, then leaves the CASE structure.

 

 

2-26 RPL Programming Examples