Sporkl Data Types


Sporkl supports the following data types:

User-defined data types - such as structs, classes, enums, etc. - are not supported.

Below are descriptions of the supported data types:

byte

A byte is an 8 bit unsigned integer. Its value can range from 0 to 255.

int

An int is a 32 bit signed integer. Its value can range from -2,147,483,648 to 2,147,483,647.

float

A float is a 64 bit floating point value. It can be in the range of +/-1.7 e+/-308, with approximately 15 significant digits of accuracy.

string

A string is a variable-length array of characters, used to contain text.

rgb

An rgb value represents a color. rgb values are accessed and stored in the RGB format, where each color component - red, green, and blue - has a byte-valued intensity.

input

An input is a handle to a user input data value. They are assigned values when user input data fields/objects are printed, and those input handles are used to obtain the resulting input data.

image

An image is an object that contains a two-dimensional array of rgb values ("points", "pixels"), and has as basic properties a width and a height (in pixels).

Constant value syntax

Integer values can be written in decimal (base 10) format in the usual way, or may be written in hexadecimal (base 16) format - hexadecimal values must be prefaced with "0x". For example, 210 can also be written as 0xd2.

Floating point values may be written in regular or exponential format. For example, 100.25 may also be written as 1.0025e2.

String values may be any series of characters enclosed by double quotes (""), except for the double-quote character itself, which must be escaped by a slash. For example, "My name is \"Plex\"!" is a valid string value, which when printed would appear as:

My name is "Plex"!

Note: Those using non-U.S. character encoding should ensure that they are using these characters - "" - as double quotes, instead of other characters which look similar (though are slanted in one or the other direction) but are not in fact recognized as double quotes by the Sporkl parser.

Other characters that need to be escaped by a slash are the slash itself, and the newline character which is written as "\n". Note that by printing the newline character, output after the newline character appears on the next line at the left of the screen. Here is an example illustrating these - the string:

"Here are quotes: \"\", here is a slash: \\, and here is a newline:\nNow here I am on the next line."

when printed is displayed as:

Here are quotes: "", here is a slash: \, and here is a newline:
Now here I am on the next line.

Some functions (such as set_char()) take character arguments. Sporkl does not support character data types, so characters must be specified as a string of length 1.

rgb, input, and image data types do not have constant values associated with them - their values must be accessed and set through the appropriate predefined functions.




( <-- Back to Sporkl documentation home )




sporkforge