RS/2 (RedTitan Script Two) is a lightweight scripting language based on Pascal.
It is intended to provide RedTitan EscapeE with a dynamic document features and
extended field processing. Three versions are available ...
Version | Deploy | Usage |
EVALUATE | EVALUATE.EEP must exist in the PLUGINS sub-directory of the ESCAPEE.EXE
software folder | Configured using EscapeE FIELD-ADVANCED. The evaluate plug-in
will engage an RS/2 program (or a simple expression) to process a field |
RTRS2IN | RTRS2IN.DLL is co-located with ESCAPEE.EXE in the software
folder. | EscapeE uses this filter to read and execute RS/2 programs (*.RS2)
or the content of an RS/2 element in IDF |
RS2 | RS2.EXE can be in any directory in the path |
RS2.EXE is a freestanding compiler and runtime system that can be used to execute
RS2 programs that do not require EscapeE capabilities. It is launched from the command line |
EscapeE drawing capablities can be accessed from an RS/2 program. (See
RS2 functions)
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. Numbers (Integer or Real)
are held internally as floating point, strings are wide (16bit characters) and
LIST is a type
unique to RS/2.
An identifier type is declared by its first use.e.g.
A:=3;
PI:=3.142;
LX:=[]; // An empty list
S:='';
- An identifier may not be re-declared as a different type.
- RS2 requires the semi-colon in every position
where Pascal permits.
- RS2 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.
The RS/2 source file is
identified by the preamble// REDTITAN RS2 CONTROL
preceded by an optional
UTF8 Byte Order Mark. In IDF notation <RS2> tag may be used to introduce an RS2 program.
The following constructs are supported
BEGIN ... END
IF ... THEN ... ELSE
CASE ... OF ...
REPEAT ... UNTIL ...
WHILE ... DO ...
FOR ... TO ... DO ...
FUNCTION ...(...) BEGIN ... END
BREAK
EXIT
There is no operator order precedence, expression evaluation is left to right.
Brackets may be be used specify an order. e.g.
writeln(3+4/5);
writeln(3+(4/5));
In RS/2 these expressions evaluate to 1.4 and 3.8
The following operators are available.
+ - * / ¬ & ! %
¬ is shorthand for NOT
& AND
! OR
% MOD
Runtime environment
RS/2 running in the freestanding RS2 compiler has access to a console (WRITELN) ,
a limited number of Windows dialogues (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.e.g.
// REDTITAN RS2 CONTROL
text(600,600,'This is page '+paramstr(1));
if paramstr(1)='5' then halt(1);
Note: The RS/2 program must signal the end of file condition to ESCAPEE
using a HALT function with an
error code greater than 0. The previous example will create a 5 page file.
Functions (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.
LIST type
An RS/2 list is a dynamic array of values. A list identifier may be instantiated
using a bracketed array of constants. e.g.
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)
To avoid problems caused by having to escape reserved charaters, an additional string constant notation
is permitted within list assignments. The '%' character denotes that the remaining characters on a line should be treated
as a string constant. This construction must be used with care because it will permit any character other than a
line break to be part of a string. e.g.
LX:=['alpha',
%"beta",alpha,3.142];
%include the rest of this line
];
A number of functions are provided to manipulate lists. The first element in an RS2 list is element 0 e.g.
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.