Hamster-Scripts: Data Types


Hamster uses a variant data-type, which can contain two basic scalar data-types: Strings or Integer.

Strings can contain any sequence of ASCII-characters, even NUL (ASCII 0). Each String can be as long as your RAM and swapfile allows.

String literals are written within double quotation marks ("This is a string"). To include a double quotation mark within a string literal, you have to double it ("This ""is"" a string").

Control codes (ASCII 0-31) should not be embedded in string literals directly, as they might be removed or modified by the editor or when saving/loading the scripts. Use chr() function to build a string containing control characters instead.

Integers are signed 32-Bit and can contain numbers in the range of -2147483648 to 2147483647. Integer-constants in hex are written with a leading "0x" (a zero-digit and a small letter "x", e.g. 0xFF).

Integers are also used to represent boolean values, where a value of 0 means FALSE and all other values mean TRUE (all built-in functions, especially "true", return a value of 1 in this case).

Where applicable, the data-types are converted automatically when needed, so if an integer is used in a string-context, it is converted to a string and vice versa.

Arrays, Hashes, Collections, Lists

There are no such data-types in Hamster-Scripts, but in many cases they can be replaced or at least be simulated by a set of list-functions. In this case, these lists are maintained internally and are accessed through a unique list-handle. See "ListAlloc" et. al. for details.

[www.elbiah.de Hamster Playground Documentation]