RDL2 data types


RDL2 supports the following scalar data types:

  • Boolean
  • Integer
  • String

RDL2 also supports the arrays and property maps as composite data types.

Default values

All variables are created with a default type of boolean and a value of false .

String data type

A string in an RDL2 script is a sequence of characters surrounded by double quotes. Any printable character is valid in a string. Certain non-printable characters are also supported using escape sequences to insert the desired character in the string:

Sequence

Character

/t

Tab character

/n

New line character

/r

Carriage return

/'

Double quote

//

Backslash

Variables

Variables are program accessible data that are referenced by a name. A variable name can be any length, and must start with a letter and contain any combination of letters (a-z, A-Z), numbers (0-9), and the underscore character after the first character.

Variable scope and lifetime

There are several scopes in which a variable may be placed:

  1. Local—A local variable's visibility is limited to the script in which it is declared. It's lifetime is limited to the execution of the script, the next time the script is invoked, it's value is the default value. Undeclared variables are assumed to be local.
  2. Session—A session variable retains it's value between script invocations, but is scoped only to scripts running within that session. Scripts running in different sessions will have their own copies of a variable even when the name is the same. Session variables are declared using the word session followed by the variable name.
  3. Global—A global variable retains its value between script invocations, and is available to all sessions. Global variables are declared using the word global followed by the variable name.

Variable conversion rules

All variables have an initial type of

boolean

and an initial value of

false

When an variable has a value assigned, it assumes the type of the value. When a variable is used within an expression, it may need to be converted to be compatible with the surrounding types. Conversion between scalar data types and composite data types will generate a compile error. Some examples:

a = false
// a is a boolean

b = true
// b is also a boolean

c = 42
// c is an integer

d = a + b + c
// all operands converted to integer

e = "a is " & a
// a converted to string and appended to the constant string

if e then
// e converted to boolean
endif

if c + 4 then
// c + 4 evaluated, then converted to boolean
endif



From

To


Boolean

integer

String

Boolean

 

true -> 1 false -> 0

true -> 'true' false -> 'false'

integer

if val is 0, -> false otherwise value -> true

 

Convert the integer to a string, e.g. 123 is converted to '123'

String

'true' -> true, otherwise the string is converted to false.

If the string can be converted into an integer, then the string is converted, otherwise 0 is used.

 

Arrays

An array is like any array in other languages, except that it maintains a dynamic size. The following are array functions:

Property maps

A property map is a collection that can contain one or more values that are indexed by a key. Property maps are similar to HashMaps in Java, or the associative array in Perl, and closely similar to Arrays in REXX. For example, a date could be set as follows:

date.day = 29 date.month = 'June' date.year = 2008

A property map can be assigned as to an element of a property map allowing for the following:

employees.fred.age = 21; employees.fred.title = 'Operations Staff Member'


Related topic

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*