======= Data types =======
TIScript is a "typeless" language in other words each variable can contain value of any type.
Each value in the language is instance of some class, e.g. integer value is an instance of class [[Integer]], etc.
===== Integer =====
Integer value is an instance of class [[Integer]] and holds signed number between Interger.MIN and Interger.MAX.
var a = 34; // integer
var b = 0xAFED1234; // integer, hexadecimal notation
var c = 'f'; // unicode code point of symbol 'f'
===== Float =====
Float value is an instance of class [[Float]] and holds signed floating point number between Float.MIN and Float.MAX.
var a = 3.14; // float
===== String =====
String is an immutable sequence of Unicode code points, see [[wp>Unicode]]. String value is an instance of class [[String]].
String literals are enclosed by quotation marks (") and can contain escape sequences \t,\a,\b,\n,\r,\v,\f,\\,\",\',\ooo,\xhh or \uhhhh.
var s = "Hello world!"; // string constant
===== Symbol =====
Symbol is a unique name internally represented by int32 value so e.g. comparison of two symbols is effective. Eeach symbol is an instance of class [[Symbol]].
Symbol literals are nmtokens prepended by pound symbol (#).
var sym = #Hello; // symbol Hello
TIScript use symbols for representing special values like ''undefined'' (#undefined), ''true'' (#true), ''false'' (#false), ''null'' (#null) etc.
:!: Note that symbol literals
symbol-literal -> '#' [a-zA-Z_$0-9-]*
support also '-' character in the name. This is made intentionally to support CSS and HTML attribute names that allow '-' inside.
So following fragment:
element.styles#line-height = px(12); // or,
element.styles[#line-height] = px(12); // equivalent of the above.
will set 'line-height' style attribute equal to 12 pixels in the [[Sciter]].
===== Boolean =====
There is no special boolean type in the language. true/false are just special constants (symbols) ''true'' and ''false''.
===== Array =====
Array is a dynamic sequence of values a.k.a. vector of values. Each array is an instance of class [[Array]].
Array literals are comma separated lists of values enclosed by '[' and ']' symbols.
var a1 = [ 1,2,3 ]; // array of three integers.
var a2 = []; // empty array
===== Object =====
Object is an associative container of name/value pairs a.k.a. map. Each object is an instance of class [[Object]] or some class derived from it.
Object literals are comma separated lists of name/value pairs enclosed by '{' and '}' symbols. Name (a.k.a. key) and value are separated by colon symbol (:).
var o1 = { one: 1, two:2, three: 3 }; // object having three fields.
var o2 = { #one: 1, #two:2, #three: 3 }; // exact equivalent of the above.
var o3 = { "one": 1, "two":2, "three": 3 }; // strings used as keys.
===== Function =====
Function is a "parametrized code block" - fragment of code with formal parameters. Functions are also objects - instances of class [[Function]]. Any variable can hold reference to a function. See also [[tiscript:functions]].
var func1 = function(parameter) { return parameter + 1;};
// short form of function literal:
var func1 = :parameter: return parameter + 1;
Variable ''func1'' here will hold reference to the (anonymous) function defined on the right.
===== Classes - user defined Types =====
TIScript allows to define new types of values (classes). User defined type may have specific set of methods, variables and constants.
See chapter [[Classes]] for more details.
===== Regexp =====
Regular expressions is a form of pattern matching that you can apply on textual content.
In Script you use forward slash (/) when you declare RegExp literals: ''/pattern/flags'';
Example:
var pattern = /[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]/g;
if( val !like pattern )
msgbox("Wrong e-mail address!");
===== Stream =====
[tbd]
===== Data (byte array) =====
[tbd]