1.04 Data Types


A variable is a data object that information for use within the program. Its value can be changed by assigning a new value.

A variable can be a single data item or it can be part of a larger structure.

A variable is defined by using the var command.

Assigning Values

Values are assigned to variables using the let command.

aa = "string"         // assign a value

Values may also be assigned by reading data from a file. See3.03 Stream Input and 3.07 File Input and Output.

Clearing Variables

A variable can be cleared back to the default value by using the let command without assigning a value.

aa =                  // reset the variable


A constant is a value that once allocated can not be changed by simple assignment. It usually contains a value that is defined outside the program such as PI. A constant can also be used to hold a value that will not change for the duration of the program.

A constant is defined by using the const command.

Defining a value as a constant prevents it being changed accidentally. It can only be changed by using the const command again.


Within LynPlex a string is a sequence of bytes. It may consist of ASCII or Unicode characters, binary data or even executable code.

By default the data type of a variable is a character string. Where a variable is used without having been assigned a value, it will default to its own name in upper case.

String Literals

A string literal is any set of characters enclosed by either single or double quote characters (' or “). Either may be used and the quote character which is not used to enclose the string may be included within the string as a character.

If the enclosing quote character is needed within the string it is entered twice and is then treated as a single character.

If the string is prefixed with an exclamation mark, escape sequences may be included within the string, otherwise they are treated literally.

Examples of string literals:

"a string"
'another string'
"a string with an embedded quote ("") character"
!"an escaped string with `na new line character"
!"an escaped string with \na new line character"


An integer is a number that does not have a fractional part. This is the default numeric data type. Integer values can be specified in decimal, hexadecimal, octal or binary form. Values using a base other than 10 may be specified using either the Basic style or the C style.

For example to assign the value of 256 to the variable x, any of the following may be used:

x = &h100 Basic hexadecimal form
x = 0x100 C hexadecimal form
x = &o400 Basic octal form
x = 0o400 C octal form
x = &b100000000 Basic binary form
x = 0b100000000 C binary form

Real or floating point numbers

If a number is specified that has a fractional part or is larger than the maximum possible integer value, it will be stored as a real (or floating point) number.

The following are examples of assigning values to real numbers:

x = .25
x = 1.2

Real numbers can be also written by using scientific notation.

1E+2 or 1E-+2, 5E--2, 2.6E-0.25, etc

Scientific Notation

In scientific notation, a number is given as a mantissa (a number with one place to the left of the decimal point) times 10 raised to an integer power.

Scientific Notation Examples:

15    is expressed as 1.5*10^1,  is typed as 1.5E+1
150   is expressed as 1.5*10^2,  is typed as 1.5E+2
1500  is expressed as 1.5*10^3,  is typed as 1.5E+3
-1500 is expressed as -1.5*10^3, is typed as -1.5E+3
0.15  is expressed as 1.5*10^-1, is typed as 1.5E-1

Numeric Literals

Numeric literals may be entered with any number of digits. For extremly large or small numbers, it is usually more convenient to use scientific notation.

lynplex/lp0104.txt · Last modified: 2012/08/22 12:55 (external edit)