Scripting Languages/ RPL Words

RPL Words

 

Following prefixes are used for variables and constants to indicate the type of the variable.

  • a - generic address
  • b - byte (8 bits)
  • e - either integer or floating point value
  • f - floating point value
  • i - long integer value (32 bits)
  • l - boolean flag. 0 denotes FALSE, any other value denotes TRUE.
  • s - address of a string
  • v - vector (consists of three floating point values)
  • w - short integer value (16 bits)
  • c - color (consists of four bytes RGBA)
  • CFA - Code Field Address. The address of a defined word in the vocabulary.
  • name - The text for a RPL token (word or variable).
  • NULL - The integer value zero.
 

Word classification

 

Miscellaneous words

( The start of an RPL comment

) Terminates a RPL comment

: The begin of a word definition.

; The end of a word definition.

& Retrieves the address of the specified word

?& Retrieves the address of a given word or 0 if not defined

ALLOCMEM Allocates memory area

EVAL Evaluates an algebraic expression

FORGET Removes definitions from the vocabulary

FREEMEM Frees memory area

LOAD Loads and executes a file containing RPL

VLIST Lists the names of all words on vocabulary

  

Stack manipulation words

.S Prints the contents of the stack without removing items

>R Moves the stack top value on the return stack

?DUP Duplicates the stack top value if it is not zero

DEPTH Puts the count of the stack items onto the stack

DROP Removes the top value from the stack

DUP Duplicates the stack top value retaining its type

OVER Copies the second stack item to the stack top code

PICK Gets a copy of a given value onto the stack top

R0 Puts on the stack the starting address of the return stack

R> Pushes a value off the return stack to the stack

RDEPTH Puts on the stack the count of the items on the return stack

ROLL Rolls a given number on items on the stack top

ROT Rotates the three topmost stack values downwards

S0 Puts on the stack the starting address of the stack

SWAP Changes the order of the two stack top values

 

Program flow control words

IF Begins a conditional structure

ELSE The beginning of the else block in a conditional structure

ENDIF Ends a conditional structure

BEGIN The beginning of an indefinite loop

AGAIN Marks the end of a BEGIN..AGAIN loop

UNTIL Marks the end of a BEGIN..UNTIL loop

REPEAT Marks the end of a BEGIN..WHILE..REPEAT loop.

WHILE Begins the WHILE section in a BEGIN..WHILE..REPEAT loop

DO Begins a definite loop

LEAVE Terminates a definite loop prematurely

LOOP Ends a definite loop

+LOOP Ends a definite loop with an arbitrary increment

I Fetches the value of the innermost loop variable on the stack

J Fetches the value of the second innermost loop variable

K Fetches the value of the third innermost loop variable  

ERROR Terminates the execution of a RPL program and prints an error

EXECUTE Executes a word given its CFA

EXIT Terminates the execution of the current word

QUIT Terminates RPL program execution and empties all stacks

?IF Begins an interactive conditional structure

?ELSE The else part of an interactive conditional block

?ENDIF The end of an interactive conditional block

 

String manipulation words

CAT Concatenates two strings

CPY Copies a string

EMIT Prints a character given its ASCII value

PUTS Prints a string

SPRINTF Formatted printing to a string

STRING Allocates memory for a named string variable

 

Integer words

CONSTANT Defines and initializes an integer constant

VARIABLE Defines a named integer variable

FETCH Fetches the value of an integer variable

STORE Stores a value to an integer variable

BFETCH Fetches the value of a byte

BSTORE Stores a value in a byte

WFETCH Fetches the value of a short integer on the stack

WSTORE Stores a value to a short integer

. Prints an integer

B. Prints an integer as a binary number

H. Prints an integer as a hexadecimal number

O. Prints an integer as an octal number

+ Integer addition

- Integer subtraction

* Integer multiplication

/ Integer division

< Integer comparison less than

<= Integer comparison less than or equal to

<> Integer comparison not equal

= Integer comparison equal

> Integer comparison greater than

>= Integer comparison greater than or equal to

MOD Modulo operation for integers

BAND Binary Boolean AND operation

BNOT Inverts the bits of an integer value

BOR Binary Boolean OR operation

BXOR Binary Boolean XOR (exclusive or) operation

NOT Logical Boolean invert

AND Logical Boolean AND operation

OR Logical Boolean OR operation

XOR Logical Boolean EXCLUSIVE OR operation

 

Floating point words

FCONSTANT Defines and initializes a named floating point constant

FVARIABLE Defines a floating point variable

FFETCH Fetches the value of a floating point variable to the stack

FSTORE Stores a value in a floating point variable

F. Prints a floating point value

F+ Floating point addition

F- Floating point subtraction

F* Floating point multiplication

F/ Floating point division

F< Floating point comparison less than

F<= Floating point comparison less than or equal to

F<> Floating point comparison not equal

F= Floating point comparison equal

F> Floating point comparison greater than

F>= Floating point comparison greater than or equal to

F>I Converts a floating point value to an integer by truncating

I>F Converts an integer to a floating point

FMOD Floating point modulo function

SIN Trigonometric sine function

COS Cosine function

TAN Trigonometric tangent function

ACOS Arcus cosine function

ASIN Arcus sine function

ATAN Arcus tangent function

EXP Computes the natural logarithm base E to the given power

POW Raises a given value to a given power

LOG The base E logarithm

LOG10 The base 10 logarithm

>RAD Converts a value given in degrees to radians

RANDOM Returns a random floating point value between 0.0 and 1.0

SQRT Square root function

 

Vector words

VCONSTANT Defines a vector constant

VVARIABLE Defines a vector variable

VFETCH Fetches the value of a vector

VSTORE Stores a vector in a variable

V. Prints a vector

VADD Vector addition

VCROSS Cross product

VDOT Dot product

VLEN Computes the length of a vector

VMUL Multiplies a vector by a scalar

VNORM Vector normalization to a unit vector

VSUB Vector subtraction

 

Vector4 words

V4CONSTANT Defines a 4-dimensional vector constant

V4FETCH Fetches the value of a 4-dimensional vector

V4STORE Stores a 4-dimensional vector in a variable

V4VARIABLE Defines a 4-dimensional vector variable

 

Word Definitions

 
 
WORD  ( 
 
TEMPLATE 
( 
 
DESCRIPTION 
This defines the start of an RPL comment. All the text after it until either ')' or EOL is ignored. 
 
NOTE 
The two comment control words '(' and ')' are defined internally and do not appear as part of the 
vocabulary. Because '(' is a RPL word, there must be at least one space between '(' and the comment 
text. Comments should be used in RPL files that may be later modified. If you enter comments in an 
interactive RPL window, they are just skipped, and are of no use. 
 
EXAMPLE 
( this is a comment ) 
VLIST ( list vocabulary 
 
 
WORD  ) 
 
TEMPLATE 
) 
 
DESCRIPTION 
Terminates a comment before EOL reached. Other words can then follow. 
 
EXAMPLE 
0 1 . ( top stack item, then second item ) . 
 
 
WORD  . 
 
TEMPLATE 
i . 
 
DESCRIPTION 
Takes a parameter off the stack and prints it as an integer value. 
 
EXAMPLE 
10 . 
15.5 . 
10 20 30 1.2 . . . . 
 
SEE ALSO 
F. H. O. B. 
 
 
WORD  .S 
 
TEMPLATE 
.S 
 
DESCRIPTION 
Prints the whole contents of the parameter stack without removing any values. 
 
 
WORD  & 
 
TEMPLATE 
& Word aWordAddr 
 
DESCRIPTION 
Retrieves the address of the specified word and places it on the stack. The word can then be stored 
in a variable and executed by EXECUTE. 
 
NOTE 
This word cannot be used inside a word definition. 
 
EXAMPLE 
: MyWord 
    "Hello World!" PUTS 
; 
 
& MyWord EXECUTE 
 
SEE ALSO 
?& EXECUTE 
 
 
WORD  + 
 
TEMPLATE 
i2 i1 + iResult 
 
DESCRIPTION 
Takes two integers off the stack, adds them, and puts the sum on the stack. 
 
EXAMPLE 
VARIABLE MyVar 
 
10 20 + MyVar STORE ( MyVar = 10 + 20 ) 
 
 
WORD  - 
 
TEMPLATE 
i2 i1 - iResult 
 
DESCRIPTION 
Takes two integers off the stack, subtracts the stack top value from the second one, and puts 
the difference on the stack. 
 
EXAMPLE 
20 10 - . ( prints the result 10 ) 
 
 
WORD  * 
 
TEMPLATE 
i2 i1 * iResult 
 
DESCRIPTION 
Takes two integers off the stack, multiplies them, and puts the product on the stack. 
 
EXAMPLE 
3 4 * . 
 
 
WORD  / 
 
TEMPLATE 
i2 i1 / iResult 
 
DESCRIPTION 
Takes two integers off the stack, divides the second value on the stack by the stack top item, 
and puts the integer part of the quotient on the stack. 
 
EXAMPLE 
10 5 / . 
 
 
WORD  : 
 
TEMPLATE 
: 
 
DESCRIPTION 
Begins a word definition. The ':' is followed by a space and the name of the RPL word to be 
defined. The name can be up to 15 characters. The definition ends with a ';'. 
 
EXAMPLE 
( define a RPL word ) 
: MyFunction 
    "this is RPL word" PUTS 
; 
 
MyFunction ( call it ) 
 
SEE ALSO 
; 
 
 
WORD  ; 
 
TEMPLATE 
; 
 
DESCRIPTION 
Ends a word definition. 
 
SEE ALSO 
: 
 
 
WORD  < 
 
TEMPLATE 
i2 i1 < lResult 
 
DESCRIPTION 
Takes two integer values off the stack and compares them. If the second value is less 
than the stack top value, < puts 1 on the stack, otherwise 0 is put on the stack. 
 
EXAMPLE 
5 7 < . ( 5 < 7, so this prints 1 ) 
 
 
WORD  <= 
 
TEMPLATE 
i2 i1 <= lResult 
 
DESCRIPTION 
Takes two integer values off the stack and compares them. If the second value is less 
than or equal to the stack top value, <= puts TRUE on the stack, otherwise FALSE 
is put on the stack. 
 
EXAMPLE 
1 3 <= . ( 1 < 3, so this prints 1 ) 
 
 
WORD  <> 
 
TEMPLATE 
i2 i1 <> lResult 
 
DESCRIPTION Takes two integer values off the stack and compares them. If the values are 
not equal, <> puts TRUE on the stack, otherwise FALSE is put on the stack. 
 
EXAMPLE 
: MyTest ( i1 i2 ) 
    <> 
    IF 
        "not equal" PUTS 
    ELSE 
        "equal values" PUTS 
    ENDIF 
; 
 
10 20 MyTest ( not equal 
5 5 MyTest ( equal values 
 
 
WORD  = 
 
TEMPLATE 
i2 i1 = lResult 
 
DESCRIPTION 
Takes two integer values off the stack and compares them. 
If the values are equal, = puts TRUE on the stack, otherwise FALSE is put on the stack. 
 
EXAMPLE 
: IsEqual ( i1 i2 ) 
    = 
    IF 
        "Yes" PUTS 
    ELSE 
        "No" PUTS 
    ENDIF 
; 
 
10 20 IsEqual ( no 
10 10 IsEqual ( yes 
 
 
WORD  > 
 
TEMPLATE 
i2 i1 > lResult 
 
DESCRIPTION 
Takes two integer values off the stack and compares them. If the second value is 
greater than the stack top value, > puts TRUE on the stack, otherwise FALSE 
is put on the stack. 
 
EXAMPLE 
10 20 > . ( 0 
10 5 > . ( 1 
 
 
WORD  >= 
 
TEMPLATE 
i2 i1 >= lResult 
 
DESCRIPTION 
Takes two integer values off the stack and compares them. If the second value is 
greater than or equal to the stack top value, >= puts TRUE on the stack, 
otherwise FALSE is put on the stack. 
 
EXAMPLE 
: IsNegative ( val ) 
    0 >= 
    IF 
        "no" PUTS 
    ELSE 
        "yes" PUTS 
    ENDIF 
; 
 
10 IsNegative ( no 
-1 IsNegatve ( yes 
0 IsNegative ( no 
 
 
WORD  >R 
 
TEMPLATE 
e >R 
 
DESCRIPTION 
Takes the top value off the stack and stores it on the return stack as an integer value. 
 
SEE ALSO 
R> 
 
 
WORD  >RAD 
 
TEMPLATE 
fDeg >RAD fRad 
 
DESCRIPTION 
Converts a value given in degrees to radians. 
 
EXAMPLE 
180.0 >RAD F. ( 3.141593 
 
 
WORD  ?& 
 
TEMPLATE 
?& name a 
 
DESCRIPTION 
Retrieves the address of a given word. If the word is not found pushes 0 onto the stack. 
 
NOTE 
This word cannot be used inside a word definition. 
 
SEE ALSO 
& EXECUTE 
 
 
WORD  ?DUP 
 
TEMPLATE 
e ?DUP e e 
 
DESCRIPTION 
Duplicates the stack top value if it is not zero. 
 
SEE ALSO 
DUP 
 
 
WORD  ?ELSE 
 
TEMPLATE 
?ELSE 
 
DESCRIPTION 
In an interactive conditional structure marks the beginning of the block that 
is to be executed when the condition fails (i.e the flag tested is FALSE). 
 
SEE ALSO 
?ENDIF ?IF ELSE ENDIF IF 
 
EXAMPLE 
( define a constant if not yet defined ) 
?& MyVar NOT 
?IF 
    1 CONSTANT MyVar 
?ENDIF 
 
 
WORD  ?ENDIF 
 
TEMPLATE 
?ENDIF 
 
DESCRIPTION 
Ends an interactive conditional structure, either ?IF..?ENDIF 
or ?IF..?ELSE..?ENDIF. 
 
SEE ALSO 
?ELSE ?IF ELSE ENDIF IF 
 
 
WORD  ?IF 
 
TEMPLATE 
l ?IF 
 
DESCRIPTION 
Begins an interactive conditional structure, either ?IF..?ENDIF or ?IF..?ELSE..?ENDIF. 
If the flag is TRUE then the words entered after ?IF will be executed immediately 
until either ?ELSE or ?ENDIF is encountered. 
 
If the flag is FALSE, the words between ?IF and ?ELSE/?ENDIF are ignored. 
Execution then resumes after ?ELSE/?ENDIF. 
 
The interactive conditional structure remains active until ?ENDIF is encountered. 
 
These interactive conditional structures may be nested. 
 
NOTE 
Interactive conditional structures can be used to control the execution of 
parts of an RPL file as it is loaded. 
 
EXAMPLE 
( check if the word VADD is already defined ) 
?& VADD 
?IF 
    "vectors.rpl already installed" PUTS 
?ELSE 
    "vectors.rpl" LOAD 
?ENDIF 
 
SEE ALSO 
?ELSE ?ENDIF ELSE ENDIF IF 
 
 
WORD  AGAIN 
 
TEMPLATE 
AGAIN 
 
DESCRIPTION 
Marks the end of a BEGIN..AGAIN loop. The BEGIN..AGAIN loop executes forever 
unless a QUIT or EXIT is executed. 
 
NOTE 
Can only be used inside a word definition. 
 
EXAMPLE 
: MyLoop 
    BEGIN 
        RANDOM 0.5 F<
        IF 
            EXIT 
        ENDIF 
    AGAIN 
; 
 
SEE ALSO 
BEGIN EXIT QUIT 

 
WORD  ALLOCMEM 
 
TEMPLATE 
iSize ALLOCMEM aAddr 
 
PARAMETERS 
iSize - the amount of memory to be allocated 
 
RETURN VALUE 
aAddr - the addres of the allocated memory 
 
DESCRIPTION 
Allocates a given amount of memory from the system and returns the address 
of the allocated hunk. If allocation fails, 0 is returned. 
 
SEE ALSO 
FREEMEM 
  
EXAMPLE 
VARIABLE aMyStr 
 
: AllocExample ( allocate 64 bytes of memory 
    64 ALLOCMEM aMyStr STORE 
    "Mary" aMyStr FETCH CPY 
    " Smith" aMyStr FETCH CAT 
    aMyStr FETCH PUTS ( Mary Smith 
    aMyStr FETCH 64 FREEMEM 
; 
  

WORD  AND 
 
TEMPLATE 
l2 l1 AND l 
 
DESCRIPTION 
Takes two boolean flags off the stack and, if they both are TRUE, puts TRUE on 
the stack, otherwise puts FALSE on the stack. The value is TRUE if it is not zero. 
 
SEE ALSO 
IF OR XOR 
 
EXAMPLE 
1 1 AND . ( 1 
0 1 AND . ( 0 
0 0 AND . ( 0 
10 20 AND . ( 1 
 
 
WORD  ACOS 
 
TEMPLATE 
f ACOS fRad 
 
RETURN VALUE 
fRad - value from 0 to PI 
 
DESCRIPTION 
Arccosine function. Computes the result in radians from a parameter, which 
must be within the interval -1 ... 1. 
 
EXAMPLE 
0.5 ACOS F. 
 
SEE ALSO 
ASIN, ATAN, COS 
 
 
WORD  ASIN 
 
TEMPLATE 
f ASIN fRad 
 
RETURN VALUE 
fRad - value from -PI/2 to PI/2 
 
DESCRIPTION 
Arcsine function. Computes the result in radians from a parameter, which 
must be within the interval -1 ... 1. 
 
EXAMPLE 
-0.5 ASIN F. 
 
SEE ALSO 
ACOS, ATAN, COS 
 
 
WORD  ATAN 
 
TEMPLATE 
f ATAN fRad 
 
RETURN VALUE 
fRad - value from -PI/2 to PI/2 
 
DESCRIPTION 
Arctangent function. Computes the result in radians. 
 
SEE ALSO 
ASIN, ACOS, TAN 
 
 
WORD  B. 
 
TEMPLATE 
i B. 
 
DESCRIPTION 
Takes an integer off the stack and prints it as a binary number. 
 
SEE ALSO 
. H. O. 
 
EXAMPLE 
1 B. ( 00000000000000000000000000000001 
2 B. ( 00000000000000000000000000000010 
3 B. ( 00000000000000000000000000000011 
4 B. ( 00000000000000000000000000000100 
 
 
WORD  BAND 
 
TEMPLATE 
i2 i1 BAND i 
 
DESCRIPTION 
Makes a binary AND operation on the two operands and puts the result on the stack. 
The result has only those bits set which are not zero in both the operands. 
 
SEE ALSO 
BNOT BOR BXOR 
 
EXAMPLE 
1 1 BAND ( 1 
2 1 BAND ( 0 
2 3 BAND ( 2 
 
 
WORD  BEGIN 
 
TEMPLATE 
BEGIN 
 
DESCRIPTION 
BEGIN marks the beginning of an indefinite loop. An indefinite loop can be 
any of the following: 
 
BEGIN..UNTIL 
BEGIN..AGAIN 
BEGIN..WHILE..REPEAT 
 
In the BEGIN..UNTIL loop a flag is tested at the end of each repetition of the loop. 
If the flag is TRUE, the loop terminates. Otherwise the loop repeats. Since the 
test is made at the end of the loop, the loop will always be executed at least once. 
 
The BEGIN..AGAIN loop executes forever unless a QUIT or EXIT is executed. 
 
In the BEGIN..WHILE..REPEAT loop the words between BEGIN and WHILE are first 
executed, and then a flag is tested. If the flag is TRUE, the words between 
WHILE and REPEAT are executed and the loop starts over. If the flag is FALSE, 
then execution skips to the word that comes after REPEAT. 
 
Indefinite loops can be nested. 
 
NOTE 
Indefinite loops can only be used inside a word definition. 
 
SEE ALSO 
UNTIL AGAIN WHILE REPEAT QUIT EXIT 
 
 
WORD  BFETCH 
 
TEMPLATE 
aByte BFETCH iValue 
 
DESCRIPTION 
Fetches the value of a byte. The address of the byte must be on the stack 
top before calling this word. 
 
NOTE 
See the note for BSTORE. 
 
SEE ALSO 
WSTORE WFETCH BSTORE 
 
 
WORD  BNOT 
 
TEMPLATE 
i1 BNOT i 
 
DESCRIPTION 
Inverts the bits of a integer value on the stack. Any bits in the integer value 
that are set (1) are reset, and any bits that are reset (0) are set. 
 
SEE ALSO 
BAND BOR BXOR 
 
 
WORD  BOR 
 
TEMPLATE 
i2 i1 BOR i 
 
DESCRIPTION 
Makes a binary OR operation on the two operands and puts the result on the stack. 
 
In a binary OR operation the result has all those bits set that have a 
corresponding bit set in either or both of the operands. 
 
SEE ALSO 
BNOT BAND BXOR 
 
EXAMPLE 
3 6 BOR ( 7 
 
 
WORD  BSTORE 
 
TEMPLATE 
b aByte BSTORE 
 
DESCRIPTION 
Stores a value in a byte. Takes the address of the variable and the value to be 
stored off the stack. 
 
NOTE 
There are no byte variables in RPL. This word is needed only when accessing 
8 bit data (like R,G,B) from Real data structures. 
 
SEE ALSO 
WSTORE WFETCH BFETCH 
 
 
WORD  BXOR 
 
TEMPLATE 
i2 i1 BXOR i 
 
DESCRIPTION 
Makes a binary XOR (exclusive or) operation on the two operands and puts the 
result on the stack. 
 
In a binary XOR operation the result has those bits set that have a 
corresponding bit set in only one of the operands. 
 
SEE ALSO 
BNOT BAND BOR 
 
 
WORD  CAT 
 
TEMPLATE 
s2 s1 CAT 
 
DESCRIPTION 
Concatenates two strings. Takes two pointers s1 and s2, and joins the string 
pointed to by s2 to the end of string pointed to by s1. 
 
The result is stored in s1. 
 
EXAMPLE 
30 STRING NAME 
 
"Mary" NAME CPY 
" Smith" NAME CAT 
NAME PUTS ( Mary Smith 
 
SEE ALSO 
CPY PUTS SPRINTF STRING 
 

WORD  CONSTANT 
 
TEMPLATE 
i CONSTANT name 
 
DESCRIPTION 
Defines a named integer constant and initializes it to the value popped 
off the stack. 
 
When the constant is later referenced by entering its name, the value 
of the constant is pushed onto the stack. 
 
NOTE 
This word is used outside of word definitions. 
 
SEE ALSO 
VARIABLE FVARIABLE FCONSTANT 
 
 
WORD  COS 
 
TEMPLATE 
f1 COS f 
 
DESCRIPTION 
Calculates the cosine of the stack top item. The operand must be in radians. 
 
SEE ALSO 
SIN 
 
EXAMPLE 
3.1416 SIN F. 
 
 
WORD  CPY 
 
TEMPLATE 
s2 s1 CPY 
 
DESCRIPTION 
Copies a string. Takes two pointers s1 and s2, and copies the string 
pointed to by s2 to the string pointed to by s1. 
 
SEE ALSO 
CAT PUTS SPRINTF STRING 
 
EXAMPLE 
100 STRING sBuf 
"Hello world" sBuf CPY 
sBuf PUTS 

 
WORD  DEPTH 
 
TEMPLATE 
DEPTH i 
 
DESCRIPTION 
Puts the count of the stack items onto the stack. 
 
SEE ALSO 
RDEPTH 
 
 
WORD  DO 
 
TEMPLATE 
i2 i1 DO 
 
DESCRIPTION 
Begins a definite loop, either DO..LOOP or DO..+LOOP. A definite loop executes 
the words inside the loop a specified number of times. The beginning (i1) 
and ending (i2) values for the loop variable are put on the stack before the 
word DO. The loop variable can be referenced using the words I, J or K 
depending on the nesting level. 
 
NOTE 
Can only be used inside a word definition. 
 
EXAMPLE 
: 5Times 
    5 0 DO 
        I . 
    LOOP 
; 
 
SEE ALSO 
LOOP +LOOP I J K 
 
 
WORD  DROP 
 
TEMPLATE 
e DROP 
 
DESCRIPTION 
Removes the top value from the stack. 
 
 
WORD  DUP 
 
TEMPLATE 
e DUP e e 
 
DESCRIPTION 
Duplicates the stack top value retaining its type (i.e. integer or floating point). 
 
SEE ALSO 
?DUP 
 
 
WORD  ELSE 
 
TEMPLATE 
ELSE 
 
DESCRIPTION 
In a conditional structure, marks the beginning of the block that is to be 
executed when the condition fails (i.e. the flag tested is FALSE). 
 
NOTE 
Can only be used inside a word definition. 
 
EXAMPLE 
: ABS ( i ABS i ) 
    DUP 
    0 >= 
    IF 
    ELSE 
    -1 * 
    ENDIF 
; 
 
SEE ALSO 
IF ENDIF 
 
 
WORD  EMIT 
 
TEMPLATE 
i EMIT 
 
DESCRIPTION 
Prints the ASCII character corresponding to the first byte of 
the top stack value. 
 
EXAMPLE 
: CR ( a carriage return and a line feed ) 
    13 EMIT 
    10 EMIT 
; 
 
"Hello" PUTS CR "World" PUTS CR 
 
 
WORD  ENDIF 
 
TEMPLATE 
ENDIF 
 
DESCRIPTION 
Ends a conditional structure, either IF..ENDIF or IF..ELSE..ENDIF. 
 
NOTE 
Can only be used inside a word definition. 
 
SEE ALSO 
IF ELSE 
 
 
WORD  ERROR 
 
TEMPLATE 
sErrorMsg ERROR 
 
PARAMETERS 
sErrorMsg - error message to be printed 
 
DESCRIPTION 
Terminates the execution of a RPL word as if an error had occurred 
and prints out the given error message. 
 
RPL programs can use this word for terminating code execution in 
situations which are not interpreted as errors by RPL. For example, 
if a procedural texture handler realizes that it cannot generate 
required color information for the renderer, it can call this word 
in order to cancel rendering. 
 
If the sErrorMsg is 0, no error message is printed. 
 
 
WORD  EVAL 
 
TEMPLATE 
sExpr EVAL f 
 
DESCRIPTION 
Evaluates an algebraic expression contained in the string pointed to 
by sExpr, and pushes the result on the stack. If the string contains 
multiple expressions then the last one evaluated determines 
the return value. 
 
The following operators are supported by the EVAL word: 
 
, - separator for multiple expressions 
( - parentheses for controlling evaluation precedence 
) - 
+ - add 
- - subtract 
* - multiply 
/ - divide 
- - negate 
^ - power 
% - modulo 
+= - x+=0.1 is same as x = x + 0.1 
-= - 
*= - 
/= - 
&& - logical AND 
|| - logical OR 
= - assignment 
== - comparison is equal 
> - comparison greater than 
< - comparison less than 
>= - comparison greater than or equal 
<= - comparison less than or equal 
!= - comparison not equal 
 
if() - if(a>b,t,f) if a > b then return t, otherwise f 
 
abs() - absolute value, for example abs(-10) produces 10 
ceil() - returns smallest integer value which is >= x 
attr() - interface to Realsoft 3D data structures 
exp() - exp(x) returns e^x 
floor() - greatest integer value which is <= x 
lg() - logarithm base 10 
ln() - natural logarithm 
max() - returns the greatest from the list 
min() - min(a,b,c,1,2) returns the smallest from the list a,b,c etc. 
sgn() - sign, sgn(x) is -1 if x < 0, 0 if x = 0 and 1 if x > 0 
sqrt() - square root 
sum() - sum(1,2,3) = 6 
 
cos() - trigonometric functions 
sin() - 
tan() - 
 
acos() - inverse trigonometric functions 
asin() - 
atan() - 
 
rnd() - rnd(min, max) returns a random value which lies between min and max. 
 
 
ceil() & floor() 
---------------- 
ceil(1.4) returns 2, floor(1.4) returns 1 and ceil(-1.4) returns -1 
 
 
WORD  EXECUTE 
 
TEMPLATE 
aCFA EXECUTE 
 
DESCRIPTION 
Executes a word given its CFA. 
 
EXAMPLE 
VARIABLE fptr 
 
: MyFunc1 "Yes" PUTS ; 
: MyFunc2 "No " PUTS ; 
 
RANDOM 0.5 F<
?IF 
    & MyFunc1 fptr STORE 
?ELSE 
    & MyFunc2 fptr STORE 
?ENDIF 
 
fptr FETCH EXECUTE 
 
SEE ALSO 
& ?& 
 
 
WORD  EXIT 
 
TEMPLATE 
EXIT 
 
DESCRIPTION 
Terminates the execution of the current word, and returns control 
to the word that executed the current word. 
 
NOTE 
Can only be used inside a word definition. 
 
EXAMPLE 
: TEST 
    DUP 
    5 <
    IF 
        DROP EXIT 
    ENDIF 
    . 
; 
 
: LUP 
    10 0 DO 
        I TEST 
    LOOP 
; 
 
SEE ALSO 
QUIT 
 
 
WORD  EXP 
 
TEMPLATE 
fPar EXP fRet 
 
DESCRIPTION 
Raises the natural logarithm base E to the fPar power. 
 
 
WORD  F. 
 
TEMPLATE 
f F. 
 
DESCRIPTION 
Takes a floating point value off the stack and prints it. 
 
SEE ALSO 
. H. O. B. 
 
 
WORD  F+ 
 
TEMPLATE 
f2 f1 F+ f 
 
DESCRIPTION 
Takes two floating point values off the stack, adds them, 
and puts the sum on the stack. 
 
EXAMPLE 
0.1 0.2 F+ F. ( 0.3 
 
 
WORD  F- 
 
TEMPLATE 
f2 f1 F- f 
 
DESCRIPTION 
Takes two floating point values off the stack, subtracts the 
stack top value from the second one, and puts the difference 
on the stack. 
 
EXAMPLE 
0.1 0.3 F- F. ( -0.2 
 
 
WORD  F* 
 
TEMPLATE 
f2 f1 F* f 
 
DESCRIPTION 
Takes two floating point values off the stack, multiplies them, 
and puts the product on the stack. 
 
 
WORD  F/ 
 
TEMPLATE 
f2 f1 F/ f 
 
DESCRIPTION 
Takes two floating point values off the stack, divides the second 
value on the stack by the stack top item, and puts the result 
on the stack. 
 
 
WORD  F< 
 
TEMPLATE 
f2 f1 F< l 
 
DESCRIPTION 
Takes two floating point values off the stack and compares them. 
If the second value is less than the stack top value, F< 
puts TRUE on the stack, otherwise FALSE is put on the stack. 
 
 
WORD  F<= 
 
TEMPLATE 
f2 f1 F<= l 
 
DESCRIPTION 
Takes two floating point values off the stack and compares them. 
If the second value is less than or equal to the stack top value 
value, F<= puts TRUE on the stack, otherwise FALSE is put 
on the stack. 
 
 
WORD  F<> 
 
TEMPLATE 
f2 f1 F<> l 
 
DESCRIPTION 
Takes two floating point values off the stack and compares them. 
If the second value is not equal to the first value, F<> 
puts TRUE on the stack, otherwise FALSE is put on the stack. 
 
 
WORD  F= 
 
TEMPLATE 
f2 f1 F= l 
 
DESCRIPTION 
Takes two floating point values off the stack and compares them. 
If the values are equal, F= puts TRUE on the stack, otherwise 
FALSE is put on the stack. 
 
 
WORD  F> 
 
TEMPLATE 
f2 f1 F> l 
 
DESCRIPTION 
Takes two floating point values off the stack and compares them. 
If the second value is greater than the stack top value, F> 
puts TRUE on the stack, otherwise FALSE is put on the stack. 
 
 
WORD  F>= 
 
TEMPLATE 
f2 f1 F>= l 
 
DESCRIPTION 
Takes two floating point values off the stack and compares them. 
If the second value is greater than or equal to the stack top 
value, F>= puts TRUE on the stack, otherwise FALSE is put 
on the stack. 
 
 
WORD  F>I 
 
TEMPLATE 
f F>I i 
 
DESCRIPTION 
Takes a floating point value off the stack and pushes a 
corresponding integer value on the stack. The decimal part 
of the floating point value is truncated in the conversion. 
 
EXAMPLE 
1.3 F>I . ( 1 
1.9 F>I . ( 1 
-1.9 F>I . ( -1 
 
SEE ALSO 
I>F 
 
 
WORD  FCONSTANT 
 
TEMPLATE 
f FCONSTANT name 
 
DESCRIPTION 
Defines a named floating point constant and initializes it to 
the value popped off the stack. 
 
When the constant is later referenced by entering its name, 
the value of the constant is pushed onto the stack. 
 
NOTE 
This word is used outside word definitions. 
 
SEE ALSO 
FVARIABLE VARIABLE CONSTANT 
 
 
WORD  FETCH 
 
TEMPLATE 
aInteger FETCH iValue 
 
DESCRIPTION 
Takes off the address of an integer variable from the stack top, 
fetches the value of the variable and puts it on the stack top. 
 
EXAMPLE 
( MyVar = MyVar + 1 ) 
MyVar FETCH 1 + MyVar STORE 
 
SEE ALSO 
STORE VARIABLE 
 
 
WORD  FFETCH 
 
TEMPLATE 
aFloat FFETCH f 
 
DESCRIPTION 
Takes off the address of a floating point variable from the stack top, 
fetches the value of the variable and puts it on the stack top. 
 
NOTE 
See the note on STORE 
 
SEE ALSO 
FSTORE FVARIABLE 
 
 
WORD  FMOD 
 
TEMPLATE 
f2 f1 FMOD f 
 
DESCRIPTION 
Takes two floating point values off the stack, divides the second 
value on the stack by the stack top item, and puts the remainder of 
the division on the stack. 
 
 
WORD  FORGET 
 
TEMPLATE 
FORGET name 
 
DESCRIPTION 
Removes definitions from the vocabulary. All words that have been 
defined after the given word, as well as the word itself, are 
removed from the Vocabulary. 
 
NOTE 
This word cannot be used inside word definitions. 
 

WORD  FREEMEM 
 
TEMPLATE 
aAddr iSize FREEMEM 
 
PARAMETERS 
aAddr - the address of the memory to be freed 
iSize - the size of the memory to be freed 
 
DESCRIPTION 
Frees the memory allocated by ALLOCMEM. 
 
SEE ALSO 
ALLOCMEM 
 
 
WORD  MOD 
 
TEMPLATE 
i2 i1 MOD i 
 
DESCRIPTION 
Takes two integers off the stack, divides the second value on 
the stack by the stack top item, and puts the remainder of the 
division on the stack. 
 
  
WORD  FSTORE 
 
TEMPLATE 
f aFloat FSTORE 
 
DESCRIPTION 
Stores a value in a floating point variable. Takes the address 
of the variable and the value to be stored off the stack. 
 
NOTE 
See the note on STORE 
 
EXAMPLE 
FVARIABLE float 
0.1 float FSTORE 
 
SEE ALSO 
FFETCH FVARIABLE 
 
 
WORD  FVARIABLE 
 
TEMPLATE 
FVARIABLE name 
 
DESCRIPTION 
Defines a named floating point variable. The name of the variable 
must follow the word FVARIABLE. The RPL interpreter allocates 
memory from the vocabulary for storing the variable. The variable 
is initialized as 0.0. 
 
When the variable is later referenced by entering its name, the 
address of the memory location that stores the variable's value 
is pushed onto the stack. 
 
NOTE 
This word is used outside word definitions. 
 
SEE ALSO 
FSTORE FFETCH FCONSTANT VARIABLE CONSTANT 
 
 
WORD  H. 
 
TEMPLATE 
i H. 
 
DESCRIPTION 
Takes an integer off the stack and prints it as a hexadecimal number. 
 
EXAMPLE 
255 H. ( ff 
 
SEE ALSO 
. O. B. 
 
 
WORD  I 
 
TEMPLATE 
I i 
 
DESCRIPTION 
Inside a definite loop copies the value of the loop variable of 
the innermost loop onto the stack. 
 
NOTE 
Can only be used inside a word definition. 
 
SEE ALSO 
J K 
 
 
WORD  I>F 
 
TEMPLATE 
i I>F f 
 
DESCRIPTION 
Takes an integer value off the stack and pushes a corresponding 
floating point value onto the stack. 
 
SEE ALSO 
F>I 
 
 
WORD  IF 
 
TEMPLATE 
l IF 
 
DESCRIPTION 
Begins a conditional structure, either IF..ENDIF or IF..ELSE..ENDIF. 
 
In the former case, if the flag is TRUE then the words between 
IF and ENDIF are executed, and then the words after ENDIF. If 
the flag is FALSE, execution skips the words between IF and ENDIF. 
 
In the latter case, if the flag is TRUE then the words between 
IF and ELSE are executed and then the words after ENDIF. If the 
flag is FALSE, the words between ELSE and ENDIF are executed and 
then the words after ENDIF. 
 
Conditional structures may be nested. 
 
NOTE 
Can only be used inside a word definition. 
 
EXAMPLE 
: PrintSign 
    DUP 0 <
    IF 
        DROP 
        "-" PUTS 
    ELSE 
        0 >
        IF 
            "+" PUTS 
        ENDIF 
    ENDIF 
; 
 
-2 PrintSign 
3 PrintSign 
0 PrintSign 
 
SEE ALSO 
ELSE ENDIF 
 
 
WORD  J 
 
TEMPLATE 
J i 
 
DESCRIPTION 
Inside a definite loop copies the value of the loop variable of the 
second innermost loop onto the stack. 
 
NOTE 
Can only be used inside a word definition. 
 
EXAMPLE 
( line feed and carriage return ) 
: CR 13 EMIT 10 EMIT ; 
 
: MULT_TABLE 
    11 1 DO 
        11 1 DO 
            I J * . 
        LOOP 
        CR 
    LOOP 
; 
 
SEE ALSO 
I K 
 
 
WORD  K 
 
TEMPLATE 
K i 
 
DESCRIPTION 
Inside a definite loop copies the value of the loop variable of 
the third innermost loop onto the stack. 
 
NOTE 
Can only be used inside a word definition. 
 
SEE ALSO 
I J 
 
 
WORD  LEAVE 
 
TEMPLATE 
LEAVE 
 
DESCRIPTION 
Terminates a definite loop prematurely. The word LEAVE causes the 
definite loop to terminate at the next LOOP or +LOOP. 
 
NOTE 
Can only be used inside a word definition. 
 
EXAMPLE 
( terminates when I squared exceeds 50 ) 
: LUP 
    10 0 DO 
    I DUP * DUP 
    50 >
    IF 
        LEAVE 
    ENDIF 
    .
    LOOP 
; 
 
SEE ALSO 
EXIT QUIT 
 
 
WORD  LOAD 
 
TEMPLATE 
sFile LOAD 
 
DESCRIPTION 
Loads a file containing RPL code. The effect is the same as if 
the text had been entered in a RPL window. The address of the 
string containing the file name is taken off the stack top. 
 
EXAMPLE 
"test.rpl" LOAD 
 
 
WORD  LOG 
 
TEMPLATE 
fPar LOG fRet 
 
PARAMETERS 
fPar - a positive parameter value 
 
DESCRIPTION 
Takes the base E logarithm. The parameter fPar must be a 
positive value. 
 
SEE ALSO 
LOG10 
 
 
WORD  LOG10 
 
TEMPLATE 
fPar LOG10 fRet 
 
PARAMETERS 
fPar - positive parameter value 
 
DESCRIPTION 
Takes the base 10 logarithm. The parameter fPar must be a positive value. 
 
SEE ALSO 
LOG 
 
 
WORD  LOOP 
 
TEMPLATE 
LOOP 
 
DESCRIPTION 
Ends a definite DO..LOOP loop. 
 
NOTE 
Can only be used inside a word definition. 
 
SEE ALSO 
DO +LOOP I J K 
 
 
WORD  +LOOP 
 
TEMPLATE 
i +LOOP 
 
DESCRIPTION 
Ends a definite DO..+LOOP loop. This word is used when the loop 
variable must be incremented by values other than 1. +LOOP takes 
the stack top value and adds it to the loop variable. 
 
If the ending value is greater than the beginning value, then the 
loop is exited if the loop variable becomes greater than or equal 
to the ending value. 
 
If the ending value is less than the beginning value, then 
the DO..+LOOP is exited when the loop variable becomes less 
than or equal to the ending value. 
 
NOTE 
Can only be used inside a word definition. 
 
EXAMPLE 
( use negative increment ) 
: Down 
    DO 
        I . 
    -1 +LOOP 
; 
0 5 Down 
 
SEE ALSO 
DO LOOP I J K 
 
 
 
WORD  NOT 
 
TEMPLATE 
l1 NOT l2 
 
DESCRIPTION 
Inverts a boolean value on the stack. If the flag is TRUE, it is 
replaced by FALSE and vice versa. Any value that is not equal to 
zero is regarded as TRUE. A value of zero is regarded as FALSE. 
 
SEE ALSO 
IF 
 
 
WORD  O. 
 
TEMPLATE 
i O. 
 
DESCRIPTION 
Takes an integer off the stack and prints it as an octal number. 
 
SEE ALSO 
. H. B. 
 
 
WORD  OR 
 
TEMPLATE 
l2 l1 OR l 
 
DESCRIPTION 
Takes two boolean flags off the stack and, if either one (or both) 
is TRUE, puts TRUE on the stack, otherwise puts FALSE on the stack. 
 
SEE ALSO 
IF AND XOR 
 
 
WORD  OVER 
 
TEMPLATE 
e2 e1 OVER e2 e1 e2 
 
DESCRIPTION 
Copies the second stack item to the stack top. 
 
SEE ALSO 
ROT ROLL PICK SWAP 
 
 
WORD  PICK 
 
TEMPLATE 
i PICK e 
 
DESCRIPTION 
Gets a copy of a value on the stack. The copied value will 
be the i'th value BEFORE the operand for PICK was entered. 
 
EXAMPLE 
10 9 8 7 .S 
4 PICK 
.S 
 
SEE ALSO 
ROLL ROT SWAP OVER 
 
 
WORD  POW 
 
TEMPLATE 
fVal fPow POW fRet 
 
DESCRIPTION 
Raises fVal to the fPow power. 
 
EXAMPLE 
2 3 POW . ( 8 
3 4 POW . ( 81 
 
 
WORD  PUTS 
 
TEMPLATE 
s PUTS 
 
DESCRIPTION 
Prints a string pointed to by s. 
 
SEE ALSO 
CAT CPY SPRINTF STRING 
 
 
WORD  QUIT 
 
TEMPLATE 
QUIT 
 
DESCRIPTION 
QUIT terminates execution of the current word, empties all 
stacks and returns control to the interpreter. 
 
SEE ALSO 
EXIT 
 
 
WORD  R0 
 
TEMPLATE 
R0 i 
 
DESCRIPTION 
Puts on the stack the starting address of the return stack. 
This is the address where the first item (usually a return 
address) on return stack is stored. 
 
SEE ALSO 
RDEPTH 
 
 
WORD  R> 
 
TEMPLATE 
R> i 
 
DESCRIPTION 
Takes an integer value off the return stack and pushes 
it onto the parameter stack. 
 
SEE ALSO 
>R 
 

WORD  RANDOM 

TEMPLATE 
RANDOM f 

DESCRIPTION 
Returns a pseudo-random floating point value between 
0.0 and 1.0 inclusive and pushes it onto the stack. 
 

WORD  RDEPTH 
 
TEMPLATE 
RDEPTH i 
 
DESCRIPTION 
Puts on the stack the count of the items on the return stack. 
 
SEE ALSO 
DEPTH 
 
 
WORD  REPEAT 
 
TEMPLATE 
REPEAT 
 
DESCRIPTION 
Marks the end of a BEGIN..WHILE..REPEAT loop. 
 
NOTE 
Can only be used inside a word definition. 
 
SEE ALSO 
BEGIN WHILE 
 
 
WORD  ROLL 
 
TEMPLATE 
i ROLL 
 
DESCRIPTION 
The word ROLL is used to rotate a given number (i) of stack 
items so that the i'th stack item becomes the stack top item 
and all the items between the first and the i'th item are moved 
one position deeper in the stack. The count i is on the stack 
top before executing ROLL. 
 
EXAMPLE 
10 9 8 7 .S 
3 ROLL 
.S 
 
SEE ALSO 
PICK ROT SWAP OVER 
 
 
WORD  ROT 
 
TEMPLATE 
e3 e2 e1 ROT e1 e3 e2 
 
DESCRIPTION 
ROT rotates the three topmost stack values so that the third item 
becomes the top item, and the first and the second item (counting 
from the stack top) will be the second and the third stack item, 
respectively. 
 
SEE ALSO 
ROLL SWAP OVER PICK 
 
 
WORD  S0 
 
TEMPLATE 
S0 i 
 
DESCRIPTION 
Puts on the stack the starting address of the parameter stack. 
This is the address where the first item on parameter stack is stored. 
 
SEE ALSO 
DEPTH 
 
 
WORD  SIN 
 
TEMPLATE 
f1 SIN f2 
 
DESCRIPTION 
Takes off the stack top item, calculates the sine of it and 
puts the result on the stack. The operand is interpreted in radians. 
 
SEE ALSO 
COS 
 
 
WORD  SPRINTF 
 
TEMPLATE 
e .. sFormat sResult SPRINTF 
 
DESCRIPTION 
This formats the operand list e .. using the format string 
specified by sFormat and stores the result in the string 
whose address is sResult. The operand list must be in 
REVERSE order as for all RPL word operands. 
 
The format string s1 controls the output format as follows: 
 
% start conversion specification. 
 
Then any of the following: 
 
- left adjust operand in its field. 
 
m digit string specifying minimum field width. 
 
. separator from field width and next digit string. 
 
n digit string specifying the maximum number of characters or 
floating point precision. 
 
Then a conversion character: 
 
c Operand is taken as a single character. 
 
d Operand is converted to decimal notation. 
 
e Operand is taken as a floating point and converted to decimal. 
 
f Operand is taken as a floating point and output as [-]mm.nnn where 
the number of digits for nnn is specified by the precision. 
 
g Use %e or %f whichever is shorter. 
 
o Operand is converted to unsigned octal notation. 
 
s Operand must be a string, and is stored until precision specification 
or the end of the string is reached. 
 
u Operand is converted to unsigned decimal notation. 
 
x Operand is converted to unsigned hexadecimal notation. 
 
NOTE 
For more information about this word consult a 'C' Language reference manual. 
 
EXAMPLE 
80 STRING Buffer 
31 "Hello, I am %d years old" Buffer SPRINTF 
Buffer PUTS 
 
SEE ALSO 
CPY CAT PUTS STRING 
 
 
WORD  SQRT 
 
TEMPLATE 
fVal SQRT fRet 
 
PARAMETERS 
fVal - A positive value 
 
DESCRIPTION 
Takes off the stack top item, calculates the square root of it and puts the result on the stack. 
 
EXAMPLE 
9 SQRT . ( 3 
0.49 SQRT F. ( 0.7 
 
 
WORD  STORE 
 
TEMPLATE 
iValue aVariable STORE 
 
DESCRIPTION 
Assigns an integer value given as the second stack item iValue to 
an integer variable pointed to by the stack top item aVariable. 
Both iValue and aVariable are taken off the stack. 
 
Integer and floating point variables must be referenced only with 
words that are for the variable type in question. For example, 
an integer variable MUST NOT be referenced using FSTORE or FFETCH, 
but only with STORE and FETCH. This is because the internal 
representations for similar integer and floating point values are different. 
 
EXAMPLE 
VARIABLE MyVar ( define an integer variable ) 
17 MyVar STORE ( stores 17 to MyVar ) 
 
SEE ALSO 
FETCH VARIABLE 
 
 
WORD  STRING 
 
TEMPLATE 
i STRING name 
 
DESCRIPTION 
Allocates memory for a named string variable. The size of the 
memory to be allocated is popped off the stack. 
 
When the string variable is later referenced by entering its 
name, the address of the first character of the string is 
pushed onto the stack. 
 
NOTE 
This word is used outside word definitions. 
 
SEE ALSO 
CPY CAT PUTS SPRINTF 
 
 
WORD  SWAP 
 
TEMPLATE 
e2 e1 SWAP e1 e2 
 
DESCRIPTION 
Changes the order of the two stack top values. 
 
SEE ALSO 
ROT ROLL PICK OVER 
 
 
WORD  TAN 
 
TEMPLATE 
f1 TAN f2 
 
DESCRIPTION 
Takes off the stack top value, computes the trigonometric 
tangent function of it, and puts the result on the stack. 
 
SEE ALSO 
SIN, COS 
 
 
WORD  UNTIL 
 
TEMPLATE 
l UNTIL 
 
DESCRIPTION 
Marks the end of a BEGIN..UNTIL loop. In the BEGIN..UNTIL 
loop a flag is tested at the end of each repetition of the loop. 
If the flag is TRUE, the loop terminates. Otherwise the loop 
repeats. Since the test is made at the end of the loop, the 
loop will always be executed at least once. 
 
NOTE 
Can only be used inside a word definition. 
 
EXAMPLE 
( print parameters until 0 found ) 
: ListScan 
    BEGIN 
        DUP 
        . 
    NOT UNTIL 
; 
 
SEE ALSO 
BEGIN 
 
 
WORD  V. 
 
TEMPLATE 
v V. 
 
PARAMETERS 
v - vector 
 
DESCRIPTION 
Pulls a vector (three float values) off the stack and prints them out. 
 
 
WORD  VADD 
 
TEMPLATE 
v1 v2 VADD vRes 
 
PARAMETERS 
v1 v2 - two vectors to be added 
 
RETURN VALUE 
vRes - the sum vector 
 
DESCRIPTION 
Vector addition. Pulls two vectors off the stack and pushes 
their sum vector on the stack. 
 
EXAMPLE 
VVARIABLE v1 VVARIABLE v2 VVARIABLE vRes 
 
1 0 0 v1 VSTORE ( v1 = 1 0 0 ) 
0 1 0 v2 VSTORE ( v2 = 0 1 0 ) 
v1 VFETCH v2 VFETCH VADD vRes VSTORE ( vRes = v1 + v2 ) 
 
 
WORD  VARIABLE 
 
TEMPLATE 
VARIABLE name 
 
DESCRIPTION 
Defines a named integer variable. The name of the variable must 
follow the word VARIABLE. The RPL interpreter allocates memory 
from the vocabulary for storing the variable. The variable is 
initialized to 0. 
 
When the variable is later referenced by entering its name, the 
address of the memory location that stores the variable's value 
is pushed onto the stack. 
 
NOTE 
This word is used outside word definitions. 
 
SEE ALSO 
STORE FETCH CONSTANT FVARIABLE FCONSTANT 
 
 
WORD  VCONSTANT 
 
TEMPLATE 
VCONSTANT name 
 
DESCRIPTION 
Defines a vector constant. 
 
EXAMPLE 
( some useful constants ) 
1 0 0 VCONSTANT vX 
0 1 0 VCONSTANT vY 
0 0 1 VCONSTANT vZ 
 
vX V. 
 
 
WORD  VCROSS 
 
TEMPLATE 
v1 v2 VCROSS vRes 
 
PARAMETERS 
v1, v2 - two vectors 
 
RETURN VALUE 
vRes - the result vector 
 
DESCRIPTION 
Cross product. Pulls two vectors off the stack and pushes their cross 
product vector on the stack. The result vector is perpendicular 
to the operands v1 and v2. 
 
EXAMPLE 
1 0 0 0 1 0 VCROSS V. ( result = 0 0 1 ) 
 
 
WORD  VDOT 
 
TEMPLATE 
v1 v2 VDOT fRes 
 
PARAMETERS 
v1, v2 - two vectors to be operated 
 
RETURN VALUE 
fRes - the dot product of the given vectors 
 
DESCRIPTION 
Pulls two vectors off the stack, computes their dot product and 
pushes the result (a floating point value) on the stack. 
 
EXAMPLE 
( dot product of perpendicular vectors ) 
1 0 0 0 1 0 VDOT F. ( = 0 
 
 
WORD  VFETCH 
 
TEMPLATE 
aVariable VFETCH fX fY fZ 
 
PARAMETERS 
aVariable - the address of a vector variable 
 
RETURN VALUE 
fX fY fZ - the contents of the variable 
 
DESCRIPTION 
Fetch the value of a vector from a given address on the stack. 
 
EXAMPLE 
( print the value of vMyVar ) 
vMyVar VFETCH V. 
 
 
WORD  VLEN 
 
TEMPLATE 
v VLEN fLen 
 
PARAMETERS 
v - any vector 
 
RETURN VALUE 
fLen - the length of v 
 
DESCRIPTION 
Pulls the given vector off the stack and puts the length of it on the stack. 
 
EXAMPLE 
10 20 30 VLEN F. 
 
 
WORD  VLIST 
 
TEMPLATE 
VLIST 
 
DESCRIPTION 
Lists the names of all words on vocabulary. 
 
 
WORD  VMUL 
 
TEMPLATE 
v f VMUL vRes 
 
PARAMETERS 
v - a vector to be multiplied 
f - a floating point value 
 
RETURN VALUE 
vRes = v1 * f 
 
DESCRIPTION 
Multiplies a vector by a scalar value. In other words, each 
component of the given vector v is multiplied by the given 
float f and the result is pushed on the stack. 
 
EXAMPLE 
( duplicate the length of a vector ) 
1.5 3.1 8.2 2.0 VMUL V. 
 
 
WORD  VNORM 
 
TEMPLATE 
v VNORM vRes 
 
PARAMETERS 
v - vector to be normalized 
 
RETURN VALUE 
vRes - a unit vector 
 
DESCRIPTION 
Vector normalization. A vector is take off the stack, divided by 
its length and the result is pushed on to the stack. 
The length of the result vector is always 1. 
 
NOTE 
Null vector becomes x-axis 1.0 0 0. 
 
EXAMPLE 
120.2 10.2 -2.1 VNORM 
 
 
WORD  VSTORE 
 
TEMPLATE 
fX fY fZ aVariable VSTORE 
 
PARAMETERS 
fX fY fZ - three values defining a vector 
aVariable - an address of a vector variable 
 
DESCRIPTION 
Store a vector in a variable. 
 
EXAMPLE 
VVARIABLE myVar 
 
0 0 1.5 myVar VSTORE 
 
 
WORD  VSUB 
 
TEMPLATE 
v1 v2 VSUB vRes 
 
PARAMETERS 
v1, v2 - vectors to be subtracted 
 
RETURN VALUE 
vRes = v1 - v2 
 
DESCRIPTION 
Pulls two vectors off the stack, subtracts the stack top 
vector from the second vector and pushes the result onto the stack. 
 
EXAMPLE 
10 5.0 0.5 ( v1 
5 5.0 0.5 ( v2 
VSUB V. ( 5.0 0.0 0.0 
 
 
WORD  VVARIABLE 
 
TEMPLATE 
VVARIABLE name 
 
DESCRIPTION 
Defines a vector variable. The name of the variable must follow t
he word VVARIABLE. The variable is initialized as 0 0 0. 
 
A vector variable is an array of three floating point variables. 
When the variable is later referenced by entering its name, the 
address of the first floating point is pushed onto the stack. 
 
EXAMPLE 
VVARIABLE myVector 
 
SEE ALSO 
VFETCH VSTORE 


WORD  V4CONSTANT 
 
TEMPLATE 
V4CONSTANT name 
 
DESCRIPTION 
Defines a 4-vector constant. 
 
EXAMPLE 
( some useful constants ) 
1 0 0 0 V4CONSTANT v4X 
 
WORD  V4FETCH 
 
TEMPLATE 
aVariable V4FETCH fX fY fZ fW
 
PARAMETERS 
aVariable - the address of a 4-vector variable 
 
RETURN VALUE 
fX fY fZ fW - the contents of the variable 
 
DESCRIPTION 
Fetch the value of a 4-vector from a given address on the stack. 
 
EXAMPLE 
( print the value of v4MyVar ) 
v4MyVar V4FETCH F. F. F. F. 
 
 
WORD  V4STORE 
 
TEMPLATE 
fX fY fZ fW aVariable V4STORE 
 
PARAMETERS 
fX fY fZ fW- four values defining a 4-vector 
aVariable - an address of a 4-vector variable 
 
DESCRIPTION 
Store a 4-vector in a variable. 
 
EXAMPLE 
V4VARIABLE myVar 
 
0 0 1.5 0 myVar V4STORE 


WORD  V4VARIABLE 
 
TEMPLATE 
V4VARIABLE name 
 
DESCRIPTION 
Defines a 4-vector variable. The name of the variable must 
follow the word V4VARIABLE. The variable is initialized as 0 0 0 0. 
 
A 4-vector variable is an array of four floating point variables. 
When the variable is later referenced by entering its name, 
the address of the first floating point is pushed onto the stack. 
 
EXAMPLE 
V4VARIABLE myVector4 
 
SEE ALSO 
V4FETCH V4STORE

 
WORD  WFETCH 
 
TEMPLATE 
aWord WFETCH i 
 
DESCRIPTION 
Takes off the address of a short integer from the stack top, 
fetches the value of the integer and puts the value on the stack. 
 
NOTE 
See note for WSTORE. 
 
SEE ALSO 
WSTORE BFETCH BSTORE 
 
 
WORD  WHILE 
 
TEMPLATE 
WHILE 
 
DESCRIPTION 
In a BEGIN..WHILE..REPEAT loop a flag is tested at the WHILE word. 
If the flag is TRUE, the words between WHILE and REPEAT are executed 
and the loop starts over. If the flag is FALSE, then execution 
skips to the word that comes after REPEAT. 
 
NOTE 
This word can only be used inside a word definition. 
 
EXAMPLE 
: TILL_TEN ( i TILL_TEN ) 
    BEGIN 
        1 + DUP 
        10 <= WHILE 
        DUP . 
    REPEAT 
    DROP 
; 
3 TILL_TEN 
 
SEE ALSO 
BEGIN REPEAT 
 
 
WORD  WSTORE 
 
TEMPLATE 
w aWord WSTORE 
 
DESCRIPTION 
Stores a value to a short integer variable pointed to by the 
stack top item. Takes the address of the variable and the 
value to be stored off the stack. 
 
This word can be used for accessing 16 bit integer fields, 
such as found from Realsoft 3D's material and object data structures. 
 
NOTE 
There are no word variables in RPL. This word is needed only 
when accessing 16 bit wide data from external data structures. 
 
SEE ALSO 
WFETCH BFETCH BSTORE 
 
 
WORD  XOR 
TEMPLATE 
l2 l1 XOR l 
 
DESCRIPTION 
Takes two boolean flags off the stack and, if one and only one of 
them is TRUE, puts TRUE on the stack, otherwise puts FALSE on the stack. 
 
SEE ALSO 
IF AND OR