Techniques used in BDISP
IFERR...THEN...END (error trap). To accommodate real-number arguments, BDISP includes the
command R"B (real-to-binary). However, this command causes an error if the argument is already a binary
integer. To maintain execution if an error occurs, the R"B command is placed inside an IFERR clause. No
action is required when an error occurs (since a binary number is an acceptable argument), so the THEN
clause contains no commands.
Enabling LASTARG. In case an error occurs, the LASTARG recovery feature must be enabled to return the
argument (the binary number) to the stack. BDISP clears flag
FOR...NEXT loop (definite loop with counter). BDISP executes a loop from 1 to 4, each time
displaying n (the number) in a different base on a different line. The loop counter (named j in this program) is
a local variable created by the FOR...NEXT program structure (rather than by a command), and
automatically incremented by NEXT.
Unnamed programs as arguments. A program defined only by its « and " delimiters (not stored in a
variable) is not automatically evaluated, but is placed on the stack and can be used as an argument for a
subroutine. BDISP demonstrates two uses for unnamed program arguments:
BDISP contains a main program argument and a call to PRESERVE. This program argument goes on the
stack and is executed by PRESERVE.
BDISP also contains four program arguments that "customize" the action of the loop. Each of these
contains a command to change the binary base, and each iteration of the loop evaluates one of these
When BDISP creates a local variable for n, the defining procedure is an unnamed program. However, since
this program is a defining procedure for a local variable structure, it is automatically executed.
PAD (Pad with Leading Spaces) expands a string to 22 characters so that DISP shows it right-justified.
PRESERVE (S) stores the current status, executes the main nested program, and restores the status.
2-8 RPL Programming Examples
55 to enable this.