The RS/2 language is a limited sub-set of Pascal.

There are no type declaration blocks and types are restricted to NUMBER, STRING, LIST and BOOLEAN.
RS/2 requires the semi-colon in every position where Pascal permits.
RS/2 has no runtime error messages. There is no exception handling.
There are no objects or class syntax. Complex types are referenced using a typed handle, e.g. File handle.
In IDF notation <RS2> tag may be used to introduce an RS/2 program.

The RS/2 source file is identified by the preamble

// REDTITAN RS2 CONTROL

Any other instance of // in a script indicates the start of a comment which RS/2 ignores. A comment is terminated at the end of the line of text.

Click to expand/collapse this hidden textIdentifiers

An identifier type is declared by its first use;

Example assignment

Type

A:=3;

Number

PI:=3.142;

Number

LX:=[];

List (empty)

S:='';

String (empty)

An identifier may not be re-declared as a different type.

Click to expand/collapse this hidden textStatements

The following constructs are supported:

BEGIN ... END

IF ... THEN ... ELSE

CASE ... OF ...

REPEAT ... UNTIL ...

WHILE ... DO ...

FOR ... TO  ... DO ...

FUNCTION ...(...) BEGIN ... END

BREAK

EXIT

Click to expand/collapse this hidden textOperators

The following operators are available:

+ addition
- subtraction
* multiplication
/ division
¬ NOT
& AND
! OR
% MOD

There is no operator order precedence, expression evaluation is left to right. Brackets may be be used specify an order.

Example writeln(3+4/5); evaluates to 1.4

Example writeln(3+(4/5)); evaluates to 3.8

Click to expand/collapse this hidden textRuntime environment

RS/2 running in the freestanding RS/2 compiler has access to a console (WRITELN), a limited number of Windows® dialogs (SHOWMESSAGE, INPUTBOX, BROWSE) and access to the filestore (OPENFILE).
RS/2 running within EscapeE may also access a number of functions to draw in the EscapeE Window. This includes line drawing, text composition, display graphical resources, and field manipulation. If EscapeE is used to open an RS/2 file, the RS/2 program is executed for every page viewed or processed. EscapeE calls the RS/2 program to draw the selected page and passes the page number as a parameter.

Click to expand/collapse this hidden textFunctions (private)

A user-defined function must be defined before first use. The formal parameter list may not contain VAR directives and may not be empty. The following function result types are permitted:

STRING
NUMBER
BOOLEAN
LIST
typed HANDLE

The private function returns a value by assigning a value to the RESULT identifier.

Click to expand/collapse this hidden textNotes on Types

NUMBER type

Numbers (Integer or Real) are held internally as floating point numbers.

STRING type

Strings are wide (16bit characters).

LIST type

An RS/2 list is a dynamic array of values, a type unique to RS/2. A list identifier may be instantiated using a bracketed array of constants:

Example LX:=['alpha',"beta",alpha,3.142];

The Pascal extended string syntax is permitted for an individual element but not mandated. As the RS/2 syntax is relaxed, comments are not allowed in constant list definitions. Note that in this example the third constant element (alpha) is treated as if it was quoted (i.e. it is not a reference to an identifier). This format is intended as a way of storing a large number of constant elements in an easy interchange format (like a paragraph of text).
A number of functions are provided to manipulate lists,

Example

LX:=['1.234',4,alpha,#13#10'new line',"element 4"];
writeln(list_numbers(lx,0)+list_numbers(lx,1));
writeln(list_strings(lx,3));
writeln(list_numbers(lx,4));

Elements are extracted from a list using the functions LIST_NUMBERS or LIST_STRINGS. Where possible there is implicit type coercion between a string and a number when the list is first created. If a string cannot be interpreted as a number the value -1 is returned.