RS/2 syntax
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. |
// 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.
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. |
The following constructs are supported: BEGIN ... END IF ... THEN ... ELSE CASE ... OF ... REPEAT ... UNTIL ... WHILE ... DO ... FOR ... TO ... DO ... FUNCTION ...(...) BEGIN ... END BREAK EXIT |
The following operators are available: + addition There is no operator order precedence, expression evaluation is left to right. Brackets may be be used specify an order. writeln(3+4/5); evaluates to 1.4 writeln(3+(4/5)); evaluates to 3.8 |
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). |
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 The private function returns a value by assigning a value to the RESULT identifier. |
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: 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). |
|
LX:=['1.234',4,alpha,#13#10'new line',"element 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. |
Links