====== Expressions ====== TIScript supports following expressions: ===== Standard ===== , = += -= *= /= %= &= |= ^= <<= >>= < expression> ? : || && | ^ & == === != !== < <= >= > << >> + - * / % instanceof // is instance of !instanceof // is *not* instance of like | // pattern matching, see below. !like | // pattern matching (inversion), see below. - ! ~ typeof // result is a symbol - name of type of the expression. ++ -- ++ -- new '(' [ ] ')' '(' [ ] ')' // function call '{' [ ] '}' // function call with single parameter - object . '[' ']' '[' [] .. [] ']' // slice of the string, array or index '#' // expr#some-symbol is a short form of expr[#some-symbol] ( ) this super null true false undefined ===== Slices ===== Slicing expression allows to create slice - fragment of sequential container. Currently only [[Array]], [[String]] and [[Index]] support slicing. var a = [ 1,2,3,4,5,6 ]; var a1 = a[ 2..4 ]; // a1 will contain array [ 3,4,5 ] var a2 = a[ 2.. ]; // a2 will contain array [ 3,4,5,6 ] var a3 = a[ ..2 ]; // a3 will contain array [ 1,2,3 ] var s = "tiscript"; var s1 = s[ 2..4 ]; // s1 will contain "scr" var s2 = s[ 2.. ]; // s2 will contain "script" var s3 = s[ ..2 ]; // s3 will contain string "tis" ===== expr#symbol form ===== TIScript supports special short form of get/set item by symbol operation - Such form is an exact equivalent of '[' ']' Examples: // non JS feature: get element by literal var o3 = { one:1, two:2, three:3, #thirty-three: 33 }; o3[#one] == 1; // true, standard access form // short form of the line above o3#one == 1; // true, short form o3#thirty-three == 33; // true, note symbol literals can contain '-' inside // In Sciter element.style#line-height = px(12); ===== like ===== Operator ''like'' tests its left side against pattern on the right side. Result of the expression is ''true'' if left side "looks like" pattern (pattern matches the string) or ''false'' - otherwise. If pattern is a string then simple VB/VBA alike pattern syntax used: ^ Characters in pattern ^ Matches in string ^ | ''?'' | Any single character. | | ''*'' | Zero or more characters. | | ''#'' | Any single digit (0–9). | | ''[charlist]'' | Any single character in charlist. | | ''[^charlist]'' | Any single character not in charlist. | Example: var fileName = "myimage.png"; r = fileName like "*.png"; // true r = fileName like "*.jpg"; // false r = fileName !like "*.png"; // false r = fileName !like "*.jpg"; // true r = fileName like "my*.png"; // true r = fileName like "my*.[a-zA-Z]ng"; // true This simple pattern matching is faster than regular expressions but can handle only simple pattern cases. ===== Function calls ===== There are two forms of function calls: normal function call and "object call" ==== normal call ==== Used when you need to pass zero or many parameters: var r1 = foo( ); var r2 = foo( param1 ); var r3 = foo( param1, param2, param3 ); ==== object call ==== Used when callee function accepts single parameter of type object: var r1 = bar{ name1:param1, name2:param2 }; The //bar// function shall accept single parameter of type object: function bar(args) { var n1 = args.name1; // will get value of param1 var n2 = args.name2; // will get value of param2 ... }