protected:
private:
\n\tstatic
, this
, super
data type | values |
---|---|
Null | null |
Boolean | true , false |
Integer | signed 32-bit integers |
Real | floating point numbers |
String | text |
Array | ordered container with integer keys |
Dictionary | associative container with string keys |
Function | function, lambda function, method |
Range | range of integers, from:to |
Type | description of a type |
operator | meaning |
---|---|
+ | addition |
- | negation, subtraction |
* | multiplication |
/ | real division |
// | integer division |
% | modulo |
^ | power |
== , != | equality |
< , <= , > , >= | order comparison |
not | logical or bitwise not |
and | logical or bitwise and |
or | logical or bitwise or |
xor | logical or bitwise exclusive or |
\n\tThe TScript language is carefully designed with the goal to create\n\tan ideal programming language for programming beginners. This\n\toverarching goal encompasses a number of sub-goals and design\n\tprinciples.\n\t
goto
statement.\n\t\tExamples are macros in C++, the division operator of Python 2,\n\t\tJavascript\'s default behavior of turning assignments to mistyped\n\t\tvariables into globals, obscure scoping rules, and improper\n\t\tinformation hiding in classes. TScript aims to be strict about\n\t\tsuch issues, in the conviction that this is the best way to\n\t\tavoid many small but hard to find errors that will frustrate\n\t\tbeginners.\n\tfor (i=0; a[i]; i++) *a[i] = *(b++) = -(c++);
\n\t\t\t\n\tThe following documents should be helpful for readers with some\n\tprogramming experience to get an quick overview of tscript:\n\t
\n\t\tTScript is an imperative and object oriented language. In many\n\t\taspects it has similarities to "scripting" languages like Python\n\t\tand Javascript: code is executed as it is encountered, so there\n\t\tis no explicit entry point, variables are untyped, they\n\t\treference values instead of containing them, and memory is fully\n\t\tmanaged.\n\t\t
\n\t\t\n\t\tFor a closer look, let\'s start with an example:\n\t\t
\n\t\tFunctions\n\t\tare declared with the
\n\t\tLike JSON, the TScript language knows the types\n\t\tnull,\n\t\tboolean,\n\t\treal (number in JSON),\n\t\tstring,\n\t\tarray, and\n\t\tdictionary (object in JSON),\n\t\tand JSON expressions are valid literals. In addition,\n\t\tTScript has a signed 32bit\n\t\tinteger type, a\n\t\trange type, a\n\t\tfunction type, and a\n\t\ttype type. Arrays are\n\t\tdenoted with square brackets and dictionaries with curly braces.\n\t\tDictionary keys can be identifiers or strings:\n\t\t
\n\t\tThe built-in types can be extended by declaring\n\t\tclasses:\n\t\t
\n\t\tFurther features of interest are\n\t\tnamespaces and\n\t\tcorresponding use directives,\n\t\tas well as exceptions.\n\t\tFor a more complete and more formal overview of the language please\n\t\trefer to the reference documentation.\n\t\t
\n\t\t\n\t\tAn important aspect of TScript as a teaching language is the closed\n\t\tand rather limited universe it lives in. The language is not designed\n\t\tas a general purpose tool, capable of interacting with arbitrary\n\t\toperating systems and libraries. Instead, its scope is limited to a\n\t\tvery specific and highly standardized working environment. It comes\n\t\twith easily accessible turtle graphics\n\t\tand canvas graphics modules. While the\n\t\tformer is ideal for visual demonstrations of programming concepts\n\t\tlike loops and recursion, the latter allows for the creating of all\n\t\tkinds of (classic) games. Check the examples\n\t\tfor demonstrations.\n\t\t
\n\t',children:[]},{id:"design",name:"Design Decisions",title:"Design Decisions",content:'\n\t\t\n\t\tMost programming languages in common use exist for an extended\n\t\tperiod of time and underwent significant changes. Such changes\n\t\tregularly aim to fix design bugs introduced early on. This naturally\n\t\tcreates a tension between designing a proper solution and avoiding\n\t\tto break existing code. Therefore many such fixes are rather newly\n\t\tdesigned workarounds. The main claim to fame of TScript is that its\n\t\tinitial design is already very well crafted, which will hopefully\n\t\tavoid the need for larger changes in the future. The most important\n\t\tfactor making this possible is that the language is very limited in\n\t\tscope, which greatly reduces the need for future changes.\n\t\t
\n\t\t\n\t\tStarting with a clean design is only possible by building on prior\n\t\t(positive and negative) experience. TScript combines well-designed\n\t\tconcepts from a range of existing programming languages — and\n\t\tsure, the decision which concepts are well-designed or not is a\n\t\tsomewhat subjective one. This affects its basic syntax, the level\n\t\tof abstraction of many concepts, as well as a number of specific\n\t\tbut important design decisions, some of which are listed in the\n\t\tfollowing.\n\t\t
\n\t\t\n\t\tIt is understood that many of these features are also present in other\n\t\tlanguages and that it is near impossible to give proper credit to every\n\t\tprogramming language out there.\n\t\t
\n\t',children:[]},{id:"arithmetics",name:"Arithmetics",title:"Arithmetics",content:'\n\t\t\n\t\tTScript has two fundamental arithmetic types: Integer and Real.\n\t\tAt first glance, they seem to be rather similar, to the extent\n\t\tthat one may conclude that Integers are superfluous, since their\n\t\tentire range is covered by Reals. Indeed, most functions and\n\t\toperators that are designed for one type accept both types, and\n\t\talso mixed types in case of multiple arguments.\n\t\t
\n\t\t\n\t\tHowever, merging the two types would clearly violate the\n\t\tsingle responsibility principle.\n\t\tThis is because integers and reals have very different (primary)\n\t\troles in the core language: integers act as array indices, while\n\t\treals are numeric values.\n\t\t
\n\t\t\n\t\tIt turns out that array indexing requires its own arithmetics,\n\t\te.g, for implementing a two-dimensional grid with an array.\n\t\tThink of a matrix stored in\n\t\trow-major format\n\t\tas an example. For a matrix of width w and height h\n\t\tand for zero-based column and row indices (x,y), the index\n\t\tof the corresponding array item is\n\t\ti=x+w*y
. The operation is inverted by\n\t\tx=i%w
and\n\t\ty=i//w
, which justifies the way\n\t\tinteger division and modulo are defined. By induction, this\n\t\targument extends to n-dimensional grids.\n
\n \n\t\t
\n\t\tThe differences between integer and floating point arithmetics\n\t\tcan be broken down to three points:\n\t\t
\n\t\tAssume for a second that the division operator would use the\n\t\tarithmetics induced by its types, then the first case would\n\t\ttrigger integer division and the statement would print zero!\n\t\t
\n\t\t\n\t\tThe problem is that in a runtime-typed language like TScript\n\t\tthe compute function cannot know which types its arguments\n\t\twill take. However, most probably the zero result is not\n\t\tintended by the programmer. Runtime type checking and forced\n\t\tconversion can fix the problem,\n\t\t
\n\t\tThis dilemma is resolved by introducing two distinct division\n\t\toperators, /
for reals and\n\t\t//
for integers. This design is not\n\t\telegant, but it solves an important problem by avoiding\n\t\tfrequent and hard-to-find division bugs. This solution is of\n\t\tcourse inspired by Python3.\n\t\t
\n\t\tThe power operator ^
is particularly\n\t\tprone to integer overflow. However, it is rarely applied with\n\t\tlarge exponents. Instead of providing a second operator that\n\t\tis more safe with respect to integer overflow, the function\n\t\tmath.pow is provided as an alternative.\n\t\t
\n\t\tAlso beyond its basic syntax, the TScript language aims to teach\n\t\tgood coding style. Therefore there exists an official style\n\t\tguide. It aims to be not too restrictive, while emphasizing a\n\t\tfew points that can make code much easier to read. These two\n\t\tpoints are:\n\t\t
\n\t\tAlthough the core language does not enforce any particular\n\t\tcoding style, it can be helpful for beginners to get used to a\n\t\tstyle that fosters readable code early on. Therefore the TScript\n\t\tIDE offers the option to enable a special style checking\n\t\tmode. In this mode, violations of this style guide are\n\t\treported as errors. The mode can be enabled/disables in the\n\t\tconfiguration dialog accessible through the toolbar.\n\t\t
\n\t\t\n\t\t\n\t\t
\n\t\tThe language syntax does not enforce indentation. Quite the\n\t\tcontrary is the case: whitespace is entirely insignificant.\n\t\tHowever, it is clear that cleanly indented code is significantly\n\t\teasier to read. Therefore, clean indentation of blocks is\n\t\tenforced by this style guide.\n\t\t
\n\t\t\n\t\tRules: Each block (scope, function/class/namespace body)\n\t\tis indented uniformly. Its indentation exceeds the indentation\n\t\tof the surrounding block. Lines containing matching opening and\n\t\tclosing braces must have the same indentation. Up to the last\n\t\trule, these rules coincide with the Python programming language.\n\t\t
\n\t\t\n\t\t
\n\t\t\n\t\tTScript uses the convention that identifiers starting with a\n\t\tcapital letter denote types, while all other identifiers denote\n\t\tvariables, functions, and namespaces.\n\t\t
\n\t\t\n\tThis tool converts resource files (image and sound data) into\n\tdata URIs\n\tas they are used with canvas.Image
and audio.Sound
objects.\n\t
\n\tSometimes error messages can be really confusing. Experienced\n\tprogrammers know how to read and interpret even seemingly obscure\n\terrors, and they have adapted to the oddities of their tools.\n\tHowever, beginners can get lost rather quickly when trying to\n\tunderstand the root cause of an error.\n\tOne reason for difficult to understand error messages is that in\n\tsome situations the parser or interpreter emitting the message would\n\thave to guess in order to determine the most probable cause of the\n\terror, while reporting only the symptoms down the road is easy.\n\t
\n\tset
, because it\n\t\tkeeps interpreting closing braces differently than the programmer\n\t\tuntil it finally encounters an unresolvable situation and\n\t\treports an error. By the time it encounters the constructor it\n\t\tknows nothing about the class being never closed by a brace,\n\t\tfrom which a really smart program may then be able to narrow down\n\t\tthe error, or at least conclude that the error's root cause could\n\t\tpossibly be found in many different places.\n\t\n\tSuch situations are hard to avoid in entirety. Therefore, when\n\tencountering a strange error it is helpful to understand how error\n\tmessages come about. For sure, the true cause of the error is found\n\tbefore the reported error position, and as the above example\n\tdemonstrates, it may be far from the position where an error is\n\tfinally reported. More often than not, the true error is in the\n\tstatement just preceding the one where an error is reported.\n\tIn addition to such general but somewhat limited insights, this\n\tsection aims to help by explaining in detail what each error message\n\tmeans, how it typically occurs, and which pitfalls one should be\n\taware of.\n\t
\n\n\t\n\tMany error messages in this documentation contain placeholders like\n\t'X' and 'Y'. In an actual error message, these placeholders are\n\treplaced with actual names. For example, the error message\n\tcannot order type 'X' in the documentation could appear in a\n\treal context as cannot order type 'Dictionary'.\n\t
\n",children:[{id:"syntax",name:"Syntax Errors",title:"Syntax Errors",content:'\n\t\t\n\t\tA syntax error indicates failure to follow the\n\t\tformal syntax\n\t\tof the language.\n\t\t
\n\t',children:[{id:"se-1",content:'\n\t\t\t\n\t\t\tThis error occurs in two situations:\n\t\t\t
.
, but the dot is not followed by a\n\t\t\t\t\tnumber, as it should.\n\t\t\t\tE
or e
,\n\t\t\t\t\tbut the indicator is not followed by a number, as it should.\n\t\t\t\t\n\t\t\tEach string literal\n\t\t\tmust end within a single line. This error indicates that the\n\t\t\tclosing double quotes character was not found before the end\n\t\t\tof the line.\n
\n\t\t\tA Unicode escape sequence in a\n\t\t\tstring literal\n\t\t\tis of the form \\uXXXX
, where each\n\t\t\tX represents a hexadecimal digit, i.e., a digit or a lower\n\t\t\tor upper case letter in the range A to F. This error is\n\t\t\treported if not all of the four characters following the \\u\n\t\t\tsequence are hex digits.\n\t\t\t
\n\t\t\tIn a\n\t\t\tstring literal,\n\t\t\tthe backslash character starts an escape sequence. Only specific codes\n\t\t\tare allowed in escape sequences, as specified\n\t\t\there. This error occurs if an\n\t\t\tinvalid code is encountered.\n\t\t\t
\n\t\t\t\n\t\t\tThis error is reported if an invalid character was encountered in the\n\t\t\tprogram. All characters are legal inside comments and string literals,\n\t\t\tbut not in the rest of the program. The exact rules which character is\n\t\t\tlegal in which context are determined by the\n\t\t\tsyntax rules.\n\t\t\tFor example, the characters @
and\n\t\t\tâ
are not legal outside comments and string\n\t\t\tliterals.\n\t\t\t
\n\t\t\tThis error can be irritating in particular if a whitespace character\n\t\t\tis reported:\n\t\t\t
\n\t\t\t
syntax error; invalid character \' \'\n\t\t\t
\n\t\t\tIn this case the program contains a whitespace that is neither a normal\n\t\t\tspace nor a tabulator. The most common such character is the\n\t\t\tnon-breaking space. It looks like a normal space character, but it is\n\t\t\tnot. On some systems it can be produced by pressing the space bar while\n\t\t\tholding the control and shift modifiers. To solve the problem, simply\n\t\t\toverwrite the non-breaking space with a normal space character (space\n\t\t\tbar).\n\t\t\t
\n\t\t',children:[]},{id:"se-6",content:"\n\t\t\t\n\t\t\tThe keyword
\n\t\t\tThe keyword
\n\t\t\tThe keyword super.name
. This error indicates that\n\t\t\tthe dot is missing after super.\n\t\t\t
\n\t\t\tThe keyword super.name
. This error indicates that\n\t\t\tthe identifier is missing after super.\n\t\t\t
\n\t\t\tThis error can occur in multiple contexts, namely when parsing the\n\t\t\tsuper class in a class declaration, in a use directive, and when\n\t\t\tparsing the loop variable of a for-loop. It indicates that a name\n\t\t\treferring to a type or variable is expected but not found.\n\t\t\t
\n\t\t",children:[]},{id:"se-13",content:'\n\t\t\t\n\t\t\tThis error message indicates that a name refers to a non-static\n\t\t\tattribute or method, which requires
\n\t\t\tA context where this error may be unintuitive at first is when\n\t\t\tusing a function name as a\n\t\t\tconstant expression,\n\t\t\ti.e., as the default value of a parameter or as the initializer\n\t\t\tof an attribute. A constant can refer to a function declaration\n\t\t\tonly if it is not a member of a class or if it is static.\n\t\t\t
\n\t\t\t\n\t\t\tWhen calling a function, all positional arguments must precede\n\t\t\tthe named arguments. This error occurs when that rule is violated\n\t\t\t
\n\t\t\t\n\t\t\tThis error indicates that a function call is broken. The argument list\n\t\t\tis a comma-separated list of expressions in parentheses. In other words,\n\t\t\teach expression is followed either by a comma or by a closing parenthesis.\n\t\t\tThe error is reported if a different token is encountered.\n\t\t\t
\n\t\t",children:[]},{id:"se-16",content:'\n\t\t\t\n\t\t\tThe formal syntax of a function call does not ensure that the object\n\t\t\tbeing called is indeed callable.\n\t\t\t
\n\t\t\t\n\t\t\tThe result of applying a left-unary of binary operator like\n\t\t\t+
is a temporary value. Assigning\n\t\t\tto this value does not make any sense, and therefore is a\n\t\t\tsyntax error.\n\t\t\t
\n\t\t\tAny expression can be enclosed in parentheses, usually for the\n\t\t\tpurpose of overriding operator precedence rules. When nesting\n\t\t\tmany parenthesis in a single expression, it is a common mistake\n\t\t\tto forget to close a parenthesis, which results in this error.\n\t\t\t
\n\t\t",children:[]},{id:"se-23",content:'\n\t\t\t\n\t\t\tA sequence of digits forms an integer token. However, an integer\n\t\t\tliteral is limited to the range 0 to 2147483647=231-1,\n\t\t\tsince otherwise overflow would apply, which is undesirable for literals.\n\t\t\tThis error indicates that the valid range was exceeded.\n\t\t\t
\n\t\t\t\n\t\t\tThis poses the difficulty of representing the smallest integer value,\n\t\t\twhich is -2147483648. It cannot be denoted as such, because its\n\t\t\tpositive counterpart exceeds the valid range, so an error occurs\n\t\t\tbefore negation is applied. Instead, the value can be denoted as\n\t\t\tfollows:\n\t\t\t
\n\t\t\t\n\t\t\tAn array literal\n\t\t\tstarts with an opening bracket [
and stops with\n\t\t\ta closing bracket ]
, enclosing a comma-separated\n\t\t\tlist of expressions. This error indicates that neither a comma nor a\n\t\t\tclosing bracket was found after an expression.\n\t\t\t
\n\t\t\tAn array literal\n\t\t\tstarts with an opening bracket [
and stops with\n\t\t\ta closing bracket ]
. This error indicates that\n\t\t\tthe end of the program was reached without encountering the closing\n\t\t\tbracket.\n\t\t\t
\n\t\t\tKeys in a dictionary must be unique. This error occurs if a\n\t\t\tdictionary literal\n\t\t\tspecifies the given key more than once.\n\t\t\t
\n\t\t\t\n\t\t\tA dictionary literal\n\t\t\tstarts with an opening brace {
and stops with\n\t\t\ta closing brace }
, enclosing a comma-separated\n\t\t\tlist of key-value pairs. This error indicates that neither a comma nor a\n\t\t\tclosing brace was found after a value.\n\t\t\t
\n\t\t\tKeys in a dictionary literal\n\t\t\tare identifiers or strings. This error is reported if neither of them\n\t\t\twas found where a key was expected.\n\t\t\t
\n\t\t',children:[]},{id:"se-29",content:'\n\t\t\t\n\t\t\tIn a dictionary literal,\n\t\t\tkeys and values are separated by colons. This error occurs is there is\n\t\t\tno colon found after the key.\n\t\t\t
\n\t\t',children:[]},{id:"se-30",content:'\n\t\t\t\n\t\t\tA dictionary literal\n\t\t\tstarts with an opening brace {
and stops with\n\t\t\ta closing brace }
. This error indicates that\n\t\t\tthe end of the program was reached without encountering the closing\n\t\t\tbrace.\n\t\t\t
\n\t\t\tAn anonymous function\n\t\t\texpression encloses variables as a comma-separated list of named expressions\n\t\t\tenclosed in square brackets. In other words, a comma or a closing bracket\n\t\t\tmust follow each variable or expression, otherwise this error is reported.\n\t\t\t
\n\n\t\t\tAn anonymous function\n\t\t\texpression encloses variables as a comma-separated list of named expressions\n\t\t\tin square brackets. It can enclose variables under their names in the\n\t\t\tsurrounding scope, or it can enclose an expression under an explicitly\n\t\t\tgiven (variable) name. In the latter case, if the variable name is missing\n\t\t\tthen this error is reported.\n\t\t\t
\n\t\t',children:[]},{id:"se-33",content:"\n\t\t\t\n\t\t\tThe parameter list of a function is a comma separated list of identifiers,\n\t\t\tpossibly with the definition of default values, enclosed in parentheses.\n\t\t\tHence, each identifier (optionally with its default value) must be followed\n\t\t\tby a comma or closing parenthesis, otherwise this error is reported.\n\t\t\t
\n\t\t",children:[]},{id:"se-35",content:'\n\t\t\t\n\t\t\tWhen using the keyword
\n\t\t\tWhen declaring a function,\n\t\t\tanonymous function,\n\t\t\tor a constructor,\n\t\t\tthen a parameter list must be defined, even if it is empty. This\n\t\t\terror indicates that the opening parenthesis was not found.\n\t\t\t
\n\t\t',children:[]},{id:"se-37",content:'\n\t\t\t\n\t\t\tA
\n\t\t\tDefault values of\n\t\t\t
\n\t\t\tThis error indicates that a namespace, class, or function body is\n\t\t\tmissing in a declaration or\n\t\t\tanonymous function.\n\t\t\t
\n\t\t',children:[]},{id:"se-41",content:"\n\t\t\t\n\t\t\tA keyword that cannot initiate an expression was detected in a context\n\t\t\twhere an expression is expected. Such contexts are manifold, i.e.,\n\t\t\ton the right-hand-side of an assignment operator, within a function\n\t\t\tcall, in the condition of a do-while or while-do loop, etc.\n\t\t\t
\n\t\t\t\n\t\t\tFor example, the keyword
\n\t\t\tA token that cannot initiate an expression was detected in a context\n\t\t\twhere an expression is expected. Such contexts are manifold, i.e.,\n\t\t\ton the right-hand-side of an assignment operator, within a function\n\t\t\tcall, in the condition of a do-while or while-do loop, etc.\n\t\t\t
\n\t\t\t\n\t\t\tFor example, integer, real and string literals are valid expressions.\n\t\t\tOn the contrary, an expression cannot start with the token\n\t\t\t,
(a comma).\n\t\t\t
\n\t\t\tA name used to\n\t\t\taccess a member\n\t\t\tof an object or a namespace is a sequence of identifiers separated\n\t\t\twith dots. This error indicates that the sequence ends with a dot,\n\t\t\tand not with an identifier, as it should.\n\t\t\t
\n\t\t',children:[]},{id:"se-44",content:'\n\t\t\t\n\t\t\tCharacters of strings and items of arrays and dictionaries are\n\t\t\taccessed with an index in square brackets.\n\t\t\tThis error indicates that the closing square bracket is missing\n\t\t\tafter the index expression.\n\t\t\t
\n\t\t',children:[]},{id:"se-47",content:'\n\t\t\t\n\t\t\tWithin a class declaration\n\t\t\tthe keyword
\n\t\t\tA second legal use of the
\n\t\t\tAn assignment ends with\n\t\t\ta semicolon. This error indicates that the semicolon was not found after\n\t\t\tthe expression on the right-hand-side of the assignment operator.\n\t\t\t
\n\t\t\t\n\t\t\tCommon reasons for this error are that\n\t\t\t
\n\t\t\tThis error indicates that an expression\n\t\t\tended in an unexpected way. When\n\t\t\tusing an expression as a statement,\n\t\t\tthe expression must be terminated with a semicolon. Alternatively, the expression\n\t\t\tcan be continued by appending a binary operator and a further expression.\n\t\t\tIf these expectations are not met then this error is reported.\n\t\t\t
\n\t\t\t\n\t\t\tCommon reasons for this error are that\n\t\t\t
\n\t\t\tIn a variable declaration,\n\t\t\tthe names of all variables must be identifiers. This error indicates that\n\t\t\ta different type of token was\n\t\t\tencountered instead.\n\t\t\t
\n\t\t',children:[]},{id:"se-51",content:'\n\t\t\t\n\t\t\tThis error indicates that the basic syntax of a\n\t\t\tvariable declaration\n\t\t\tis violated. Variables are separated with commas, the list closes with a\n\t\t\tsemicolon, and each variable can have an initializer starting with an\n\t\t\tequals sign. Therefore the identifier must be followed by an equals sign,\n\t\t\ta comma, or a semicolon. Otherwise this error is reported.\n\t\t\t
\n\t\t',children:[]},{id:"se-51b",content:'\n\t\t\t\n\t\t\tThis error indicates that the basic syntax of a\n\t\t\tvariable declaration\n\t\t\tis violated. Variables are separated with commas, the list closes with a\n\t\t\tsemicolon. Therefore the initializer must be followed by a comma or a\n\t\t\tsemicolon. Otherwise this error is reported.\n\t\t\t
\n\t\t',children:[]},{id:"se-52",content:'\n\t\t\t\n\t\t\tA function declaration\n\t\t\tmust have a name, which is an identifier. This error indicates that the\n\t\t\tname was not found after the
\n\t\t\tOne possible cause of this error is the attempt to denote an anonymous\n\t\t\tfunction in an expression forming a statement. This does not work directly,\n\t\t\tsince the
\n\t\t\tThe constructor of a class\n\t\t\tcan invoke the constructor of the super class with a special syntax,\n\t\t\t
\n\t\t',children:[]},{id:"se-54",content:'\n\t\t\t\n\t\t\tA class declaration\n\t\t\tcontains an identifier acting as the name of the class. This error\n\t\t\tindicates that no identifier was found after the keyword\n\t\t\t
\n\t\t\tAn access modifier in a class declaration\n\t\t\tconsists of one of the keywords
\n\t\t\tAll members of a class\n\t\t\tare subject to a visibility modifier, consisting of one of the keywords\n\t\t\t
\n\t\t\tAttributes of a class\n\t\t\tcan be initialized in their declaration by providing an initializer.\n\t\t\tThis works for static as well as for non-static attributes. However,\n\t\t\tin contrast to global and local variables, the initializer must be\n\t\t\ta constant.\n\t\t\t
\n\t\t',children:[]},{id:"se-58",content:'\n\t\t\t\n\t\t\tAll members of a class\n\t\t\tare subject to visibility settings. The constructor of a class always\n\t\t\tcalls the constructor of the super class. This even holds for the\n\t\t\tdefault constructor, which is generated if no constructor is\n\t\t\texplicitly declared.\n\t\t\t
\n\t\t\t\n\t\t\tIf the super class has declared its constructor private then the\n\t\t\tsub-class cannot properly initialize the super class. Therefore\n\t\t\tinheriting a class with private constructor is not possible.\n\t\t\t
\n\t\t',children:[]},{id:"se-59",content:'\n\t\t\t\n\t\t\tThe constructor of a class\n\t\t\tneeds a
\n\t\t\tThe constructor of a class\n\t\t\tmust be unique, it cannot be overloaded. This is explicitly different from other\n languages. Remove all but one constructor\n\t\t\tto fix this error.\n\t\t\t
\n\t\t',children:[]},{id:"se-60",content:'\n\t\t\t\n\t\t\tThe only members of a class\n\t\t\tthat can be declared are attributes and methods. This error indicates that\n\t\t\ta class declaration found inside the scope of another class is declared\n\t\t\tstatic.\n\t\t\t
\n\t\t',children:[]},{id:"se-61",content:'\n\t\t\t\n\t\t\tThe only members of a class\n\t\t\tthat can be declared are attributes and methods. This error indicates that\n\t\t\ta use directive found inside the\n\t\t\tscope of another class is declared static.\n\t\t\t
\n\t\t',children:[]},{id:"se-62",content:'\n\t\t\t\n\t\t\tThis error indicates that an unexpected entity was found inside a\n\t\t\tclass. The class syntax\n\t\t\tdemands that only access modifiers, attribute and method declarations,\n\t\t\tdeclarations of nested classes, and use-directives are allowed.\n\t\t\t
\n\t\t',children:[]},{id:"se-63",content:'\n\t\t\t\n\t\t\tAs the error message states, a\n\t\t\tnamespace can be\n\t\t\tdeclared only at global scope or nested within another namespace.\n\t\t\tIt must not be declared at function of class scope. The error\n\t\t\tmessage indicates that this rule was violated.\n\t\t\t
\n\t\t',children:[]},{id:"se-64",content:'\n\t\t\t\n\t\t\tA namespace declaration\n\t\t\tcontains an identifier acting as the name of the class. This error\n\t\t\tindicates that no identifier was found after the keyword\n\t\t\t
\n\t\t\tUse directives can have two forms.\n\t\t\tThis error occurs if the form starting with
\n\t\t\tIn a use directive, an imported name\n\t\t\tcan be remapped to a different name with an
\n\t\t\tThis error indicates that the
\n\t\t\tIn a use directive, multiple names\n\t\t\tor whole namespaces can be imported. The individual imports are separated\n\t\t\twith commas, and the overall use directive closes with a semicolon. Therefore\n\t\t\teach import must be followed either by a comma or by a semicolon. This error\n\t\t\tindicates that the above rule is violated.\n\t\t\t
\n\t\t',children:[]},{id:"se-69",content:'\n\t\t\t\n\t\t\tThe error indicates that in an\n\t\t\tif-then-else conditional\n\t\t\tstatement the keyword
\n\t\t\tA for loop uses a loop\n\t\t\tvariable to indicate its current iteration. If this variable is declared\n\t\t\twithin the loop with the
\n\t\t\tIn a for loop declaring its\n\t\t\town loop variable, the keyword
\n\t\t\tIn a for loop after the\n\t\t\tcontainer to loop over must be followed by the keyword
\n\t\t\tIf a for loop does not use\n\t\t\tloop variable declared within the loop, then the expression following\n\t\t\tthe keyword
\n\t\t\tThe syntax of a do-while loop\n\t\t\tdemands that the loop body is followed by the keyword
\n\t\t\tThe syntax of a do-while loop\n\t\t\tdemands that the condition is followed by a semicolon.\n\t\t\tThis error message indicates that an different token was encountered.\n\t\t\tIt may indicate that the expression representing the loop condition\n\t\t\tis broken.\n\t\t\t
\n\t\t',children:[]},{id:"se-76",content:'\n\t\t\t\n\t\t\tThe syntax of a while-do loop\n\t\t\tdemands that the condition is followed by the keyword
\n\t\t\tA break statement\n\t\t\tcan only appear inside a loop. This error message indicates that there\n\t\t\tis no loop surrounding the statement.\n\t\t\t
\n\t\t',children:[]},{id:"se-78",content:'\n\t\t\t\n\t\t\tA continue statement\n\t\t\tcan only appear inside a loop. This error message indicates that there\n\t\t\tis no loop surrounding the statement.\n\t\t\t
\n\t\t',children:[]},{id:"se-79",content:'\n\t\t\t\n\t\t\tA return statement returns\n\t\t\tthe control flow from the current function back to the calling context.\n\t\t\tWhen doing so, it can also return a value, which then becomes the value\n\t\t\tof the function call expression. However, a constructor does not evaluate\n\t\t\tto an arbitrary expression and therefore cannot return a value. A return\n\t\t\tstatement inside a constructor must not contain a return value, otherwise\n\t\t\tthis error is reported.\n\t\t\t
\n\t\t',children:[]},{id:"se-80",content:'\n\t\t\t\n\t\t\tA return statement returns\n\t\t\tthe control flow from the current function back to the calling context.\n\t\t\tWhen doing so, it can also return a value, which then becomes the value\n\t\t\tof the function call expression. When applied at global or namespace\n\t\t\tscope, the return statement ends the program. Since a program does not\n\t\t\thave a value, a return statement at global or namespace scope must not\n\t\t\tcontain a return value, otherwise this error is reported.\n\t\t\t
\n\t\t',children:[]},{id:"se-81",content:'\n\t\t\t\n\t\t\tA return statement ends with\n\t\t\ta semicolon. The error message indicates that this is not the case.\n\t\t\tThe most probably reason is that the return expression is broken.\n\t\t\t
\n\t\t',children:[]},{id:"se-81b",content:'\n\t\t\t\n\t\t\tA break statement ends with\n\t\t\ta semicolon. The error message indicates that this is not the case.\n\t\t\t
\n\t\t',children:[]},{id:"se-81c",content:'\n\t\t\t\n\t\t\tA continue statement ends with\n\t\t\ta semicolon. The error message indicates that this is not the case.\n\t\t\t
\n\t\t',children:[]},{id:"se-82",content:'\n\t\t\t\n\t\t\ttry-catch\n\t\t\t
\n\t\t',children:[]},{id:"se-84",content:'\n\t\t\t\n\t\t\ttry-catch\n\t\t\t
\n\t\t',children:[]},{id:"se-85",content:'\n\t\t\t\n\t\t\ttry-catch\n\t\t\t
\n\t\t',children:[]},{id:"se-86",content:'\n\t\t\t\n\t\t\ttry-catch\n\t\t\t
\n\t\t',children:[]},{id:"se-87",content:'\n\t\t\t\n\t\t\tA throw statements ends with\n\t\t\ta semicolon. This error message indicates that the semicolon is missing.\n\t\t\tThe most probably cause of this error is a bug in the expression preceding\n\t\t\tthe semicolon.\n\t\t\t
\n\t\t',children:[]},{id:"se-88",content:'\n\t\t\t\n\t\t\tCurly braces can close\n\t\t\tblocks of statements and\n\t\t\tdictionary literals.\n\t\t\tThis error indicates that a closing brace was found in a different\n\t\t\tcontext. The most common cause of this error is that the declaration\n\t\t\tor statement preceding the closing brace is broken.\n\t\t\t
\n\t\t',children:[]},{id:"se-89",content:"\n\t\t\t\n\t\t\tThis error is reported if a keyword that cannot start a statement\n\t\t\t(like, e.g.,
\n\t\t\tThis error is reported if a token that cannot start a statement\n\t\t\t(like, e.g., +=
) was encountered where a\n\t\t\tstatement was expected. This error usually indicates that the\n\t\t\tstatement directly preceding the location where the error is\n\t\t\treported is broken.\n\t\t\t
\n\t\t\tThis error is reported if the include "filename";
. For example, an\n\t\t\tattempt to use the function-style syntax\n\t\t\tinclude("filename");
\n\t\t\tresults in this error.\n\t\t\t
\n\t\t\tThis error indicates that the semicolon ending an\n\t\t\t
\n\t\tValues passed into a function or operator can mismatch the needs\n\t\tand expectations of the function being called in several ways.\n\t\tArguments can be of the wrong type, or their values can be in an\n\t\tinvalid range. Errors in this category reflect such events.\n\t\t
\n\t",children:[{id:"am-1",content:'\n\t\t\t\n\t\t\tA function specifies how many arguments it expects, but the formal\n\t\t\tfunction declaration does not specify which types can be processed.\n\t\t\tFor example, the wait function expects the number of milliseconds\n\t\t\tto wait as an argument, which must be a number. If a value of\n\t\t\tunrelated type is passed, say, a dictionary, then the function\n\t\t\treports this error.\n\t\t\t
\n\t\t\t\n\t\t\tSuch errors occur for two frequent reasons.\n\t\t\t
\n\t\t\tThe unary operator not\n\t\t\tis only defined for boolean arguments. Applying unary not\n\t\t\tto a value of any other type results in this error.\n\t\t\t
\n\t\t',children:[]},{id:"am-3",content:'\n\t\t\t\n\t\t\tThe unary operator +\n\t\t\tis only defined for numerical arguments. Applying unary plus\n\t\t\tto a value of any other type results in this error.\n\t\t\t
\n\t\t',children:[]},{id:"am-4",content:'\n\t\t\t\n\t\t\tThe unary operator -\n\t\t\tis only defined for numerical arguments. Applying unary minus\n\t\t\tto a value of any other type results in this error.\n\t\t\t
\n\t\t',children:[]},{id:"am-5",content:'\n\t\t\t\n\t\t\tThis error occurs if the\n\t\t\tbinary operator +\n\t\t\tis applied to two types that cannot be added. The operator supports\n\t\t\tnumeric types as well as string concatenation. All other operand\n\t\t\ttypes result in this error.\n\t\t\t
\n\t\t',children:[]},{id:"am-6",content:'\n\t\t\t\n\t\t\tThis error occurs if the\n\t\t\tbinary operator -\n\t\t\tis applied to non-numeric arguments.\n\t\t\t
\n\t\t',children:[]},{id:"am-7",content:'\n\t\t\t\n\t\t\tThis error occurs if the\n\t\t\tbinary operator +\n\t\t\tis applied to non-numeric arguments.\n\t\t\t
\n\t\t',children:[]},{id:"am-8",content:'\n\t\t\t\n\t\t\tThis error occurs if the\n\t\t\tbinary operator /\n\t\t\tor the\n\t\t\tbinary operator //\n\t\t\tis applied to non-numeric arguments.\n\t\t\t
\n\t\t',children:[]},{id:"am-9",content:'\n\t\t\t\n\t\t\tThis error occurs if the\n\t\t\tbinary operator %\n\t\t\tis applied to non-numeric arguments.\n\t\t\t
\n\t\t',children:[]},{id:"am-10",content:'\n\t\t\t\n\t\t\tThis error occurs if the\n\t\t\tbinary operator ^\n\t\t\tis applied to non-numeric arguments.\n\t\t\t
\n\t\t',children:[]},{id:"am-11",content:'\n\t\t\t\n\t\t\tThis error occurs if the\n\t\t\tbinary operator :\n\t\t\tis applied to non-integer arguments.\n\t\t\t
\n\t\t',children:[]},{id:"am-12",content:'\n\t\t\t\n\t\t\tThis error occurs if one of the binary operators\n\t\t\tand,\n\t\t\tor, or\n\t\t\txor\n\t\t\tis applied to non-boolean non-integer arguments.\n\t\t\t
\n\t\t',children:[]},{id:"am-13",content:'\n\t\t\t\n\t\t\tThis error occurs when a value is converted to an integer. The\n\t\t\tvalue is often a real, but it can also be a string that is\n\t\t\tinterpreted as a real. If the real is not a finite value or if\n\t\t\tthe string representation overflows to an infinite value then\n\t\t\tthe error occurs. It is an error because integers cannot\n\t\t\trepresent infinity and not-a-number, and also the integer\n\t\t\toverflow rules are unsuitable to resolve this situation.\n\t\t\t
\n\t\t\t\n\t\t\tThis error occurs when a string is converted to an integer\n\t\t\tand the string value does not represent a number.\n\t\t\t
\n\t\t\t\n\t\t\tThis error occurs when a value is divided by zero with the\n\t\t\tinteger division operator //
or\n\t\t\twith the modulo operator %
. As an\n\t\t\texception, integer division by zero applied to type\n\t\t\tReal results in an\n\t\t\tinfinite value or not-a-number (NaN).\n\t\t\tIn contrast to this behavior, the real division operator\n\t\t\t/
does not emit an error and\n\t\t\talways produces an infinite result or not-a-number.\n\t\t\t
\n\t\t\tThis error usually occurs when dividing by a variable or by\n\t\t\tthe result of a complex expression the value of which was not\n\t\t\tforeseen by the programmer to be zero. Example:\n\t\t\t
\n\t\t\tValues are said to be ordered if they can be compared with operators\n\t\t\t<
, <=
,\n\t\t\t>
, and >=
.\n\t\t\tThe rules for ordering values are found\n\t\t\there.\n\t\t\tFor example, arrays can be ordered, while dictionaries cannot.\n\t\t\t
\n\t\t\tThis error occurs frequently if one of the operands of the comparison\n\t\t\tis of a type the programmer did not expect. E.g., a function like\n\t\t\tString.find usually returns a\n\t\t\tnumber, but in occasional error conditions it returns null. Therefore\n\t\t\ta statement like\n\t\t\t
\n\t\t\tValues are said to be ordered if they can be compared with operators\n\t\t\t<
, <=
,\n\t\t\t>
, and >=
.\n\t\t\tThe rules for ordering values are found\n\t\t\there.\n\t\t\tFor example, arrays can be ordered, while dictionaries cannot.\n\t\t\tIn most cases, values of different types cannot be ordered. Integer\n\t\t\tand Real are exceptions:\n\t\t\t
\n\t\t\tThis error occurs frequently if one of the operands of the comparison\n\t\t\tis of a type the programmer did not expect. E.g., a function like\n\t\t\tString.find usually returns a\n\t\t\tnumber, but in occasional error conditions it returns null. Therefore\n\t\t\ta statement like\n\t\t\t
\n\t\t\tWhen calling the Array constructor with an integer as the first\n\t\t\targument, an array of the given size is created. If this size is\n\t\t\tnegative then this error is reported.\n\t\t\t
\n\t\t\t\n\t\t\tThis error occurs if the expression controlling the array size\n\t\t\thappens to become negative, which was usually not anticipated by\n\t\t\tthe programmer.\n\t\t\t
\n\t\t',children:[]},{id:"am-18",content:'\n\t\t\t\n\t\t\tThe Array.insert function\n\t\t\ttakes a position within the array as its argument. The position\n\t\t\tmust neither be negative nor exceed the array length. If it does,\n\t\t\tthen this error is reported.\n\t\t\t
\n\t\t\t\n\t\t\tThis error occurs if the expression controlling the array position\n\t\t\thappens to take values not anticipated by the programmer.\n\t\t\t
\n\t\t',children:[]},{id:"am-18b",content:'\n\t\t\t\n\t\t\tThe Array.pop function removes\n\t\t\tthe last item of the array, which is returned. If the array is\n\t\t\tempty and hence there is no item to remove and return then this\n\t\t\terror is reported.\n\t\t\t
\n\t\t',children:[]},{id:"am-19",content:'\n\t\t\t\n\t\t\tThe Array.sort function can\n\t\t\tsort the array according to a user-specificed order relation,\n\t\t\tdefined by the \'comparator\' function passed as an argument to\n\t\t\tArray.sort. Given two items as arguments, this function must\n\t\t\treturn a numeric value. If the value is non-numeric, then this\n\t\t\terror is reported.\n
\n\t\t\tThis error is reported if the items of a\n\t\t\tstring are\n\t\t\taccessed\n\t\t\twith an invalid index of key type. Valid index types are\n\t\t\tinteger and range.\n\t\t\t
\n\t\t',children:[]},{id:"am-21",content:'\n\t\t\t\n\t\t\tWhen accessing\n\t\t\ta single character of a string\n\t\t\tas an integer code, the index must be a valid position within the\n\t\t\tstring. This error indicates that the index is negative.\n\t\t\t
\n\t\t',children:[]},{id:"am-22",content:'\n\t\t\t\n\t\t\tWhen accessing\n\t\t\ta single character of a string\n\t\t\tas an integer code, the index must be a valid position within the\n\t\t\tstring. This error indicates that the index exceeds the valid range,\n\t\t\twhich is upper bounded by the string size.\n\t\t\t
\n\t\t',children:[]},{id:"am-23",content:'\n\t\t\t\n\t\t\tWhen accessing an item\n\t\t\tof an array, a valid (zero-based) index is neither negative, not does it\n\t\t\texceed the size of the array. This error indicates that the index is\n\t\t\tnegative. This error is usually caused by an expression evaluating to a\n\t\t\tnegative number, which was not anticipated by the programmer.\n\t\t\t
\n\t\t',children:[]},{id:"am-24",content:'\n\t\t\t\n\t\t\tWhen accessing an item\n\t\t\tof an array, a valid (zero-based)\n\t\t\tindex is neither negative, not does it exceed the size of the array.\n\t\t\tThis error indicates that the index is at least at large as the array size.\n\t\t\tThe error is usually caused by an expression evaluating to a too large\n\t\t\tnumber, which was not anticipated by the programmer.\n\t\t\t
\n\t\t',children:[]},{id:"am-25",content:'\n\t\t\t\n\t\t\tWhen accessing an item\n\t\t\tof an array, a valid index is of\n\t\t\ttype integer or range. If the expression is on the left-hand-side of an\n\t\t\tassignment operator, then the only valid index type is an integer. This\n\t\t\terror indicates that the index expression evaluates to a different type.\n\t\t\t
\n\t\t',children:[]},{id:"am-26",content:'\n\t\t\t\n\t\t\tWhen accessing an item\n\t\t\tof an array, a valid index is of\n\t\t\ttype integer or range. This error indicates that the index expression\n\t\t\tevaluates to a different type.\n\t\t\t
\n\t\t',children:[]},{id:"am-27",content:'\n\t\t\t\n\t\t\tWhen accessing an item\n\t\t\tof a dictionary, the index\n\t\t\tmust be a key of the dictionary. This error indicates that the index was\n\t\t\tnot found as a key in the dictionary.\n\t\t\t
\n\t\t',children:[]},{id:"am-28",content:'\n\t\t\t\n\t\t\tWhen accessing an item\n\t\t\tof a dictionary, a valid key\n\t\t\tis of type string. This error indicates that the index expression\n\t\t\tevaluates to a different type.\n\t\t\t
\n\t\t',children:[]},{id:"am-29",content:'\n\t\t\t\n\t\t\tWhen accessing an item\n\t\t\tof a range, the index must be a\n\t\t\tvalid index of an array representing the elements of the range. This\n\t\t\tmeans that it must not be negative, and it must be less than the size of\n\t\t\tthe range. This error indicates that the index is outside these bounds.\n\t\t\t
\n\t\t',children:[]},{id:"am-30",content:'\n\t\t\t\n\t\t\tWhen accessing an item\n\t\t\tof a range, the index must be a of\n\t\t\ttype integer or range. This error indicates that the index expression\n\t\t\tevaluates to a different type.\n\t\t\t
\n\t\t',children:[]},{id:"am-31",content:'\n\t\t\t\n\t\t\tThe access operator\n\t\t\tprovides access to the items of a container. The only types supporting\n\t\t\tthis mechanism are string, array, dictionary, and range. This error\n\t\t\tindicates that it was attempted to access an item of a different type.\n\t\t\t
\n\t\t',children:[]},{id:"am-31b",content:'\n\t\t\t\n\t\t\tThe access operator\n\t\t\tprovides access to the items of a container. The only types supporting\n\t\t\tthis mechanism when used on the left-hand-side of an assignment are\n\t\t\tarray and dictionary. This error indicates that it was attempted to\n\t\t\tset an item of a different type.\n\t\t\t
\n\t\t',children:[]},{id:"am-32",content:'\n\t\t\t\n\t\t\tThe left-hand side of an\n\t\t\tassignment operator\n\t\t\tis an expression. However, not all expressions can be assigned to.\n\t\t\tThis error indicates that it was attempted to assign to an expression\n\t\t\tthat does not refer to a variable in which the result of the\n\t\t\tright-hand-side can be stored.\n\t\t\t
\n\t\t',children:[]},{id:"am-33",content:'\n\t\t\t\n\t\t\tThe condition in an\n\t\t\tif-then-else\n\t\t\tstatement decides whether the then-branch or the else-branch is\n\t\t\texecuted. The expression must evaluate to a\n\t\t\tboolean value, otherwise\n\t\t\tthis error is triggered.\n\t\t\t
\n\t\t',children:[]},{id:"am-34",content:'\n\t\t\t\n\t\t\tA for-loop iterates\n\t\t\tover the items of a range or array. If the expression defining the\n\t\t\tcontainer evaluates to a different type then this error is emitted.\n\t\t\t
\n\t\t',children:[]},{id:"am-35",content:'\n\t\t\t\n\t\t\tA for-loop stores\n\t\t\tthe current item of the container it iterates over in a variable.\n\t\t\tIt this variable is not declared inside the loop, then an arbitrary\n\t\t\tname can be provided. This name must refer to a variable, otherwise\n\t\t\tthis error is triggered.\n\t\t\t
\n\t\t',children:[]},{id:"am-36",content:'\n\t\t\t\n\t\t\tThe condition in a\n\t\t\tdo-while loop\n\t\t\tdecides whether to stop or to continue the loop. The expression\n\t\t\tmust evaluate to a boolean\n\t\t\tvalue, otherwise this error is triggered.\n\t\t\t
\n\t\t',children:[]},{id:"am-37",content:'\n\t\t\t\n\t\t\tThe condition in a\n\t\t\twhile-do loop\n\t\t\tdecides whether to stop or to continue the loop. The expression\n\t\t\tmust evaluate to a boolean\n\t\t\tvalue, otherwise this error is triggered.\n\t\t\t
\n\t\t',children:[]},{id:"am-38",content:'\n\t\t\t\n\t\t\tLoading a value with the standard library\'s\n\t\t\tload
function failed because the key does\n\t\t\tnot exist.\n\t\t\t
\n\t\t\tThis error occurs when trying to load a value from a key that was\n\t\t\tnot saved before. Use the exists
function\n\t\t\tto check whether a key exists.\n\t\t\t
\n\t\t\tSaving a value with the standard library\'s save
\n\t\t\tfunction failed. This happens for two reasons.\n\t\t\t
\n\t\t\tThe first and more usual cause is that the value is not a\n\t\t\tJSON constant.\n\t\t\tValues of type Null, Boolean, Integer, Real, and String are legal,\n\t\t\tas well as Array and Dictionary, if all of the values stored\n\t\t\ttherein are legal JSON values and the data structure is an\n\t\t\tacyclic graph (a tree).\n\t\t\t
\n\t\t\t\n\t\t\tThis error occurs if the value to be stored is or contains a value\n\t\t\tof a disallowed type, like a Range, Function, Type, or a user-defined\n\t\t\tclass. This error is also reported if the data structure is recursive,\n\t\t\ti.e., if an array or dictionary contains itself as a value, possibly\n\t\t\tindirectly.\n\t\t\t
\n\t\t\t\n\t\t\tThe second reason is that the storage is full, i.e., its quota is\n\t\t\texceeded. Webservers usually allow to store data in the order of a\n\t\t\tfew megabytes per origin. When that space is full and the value to\n\t\t\tbe stored would exceed the quota, then this error is reported.\n\t\t\t
\n\t\t\t\n\t\t\tNote that the available space is shared between saved programs\n\t\t\t(usually not very much data) and data stored by all programs.\n\t\t\tTo avoid this error, it can make sense to remove unneeded entries\n\t\t\tfrom the browser\'s local storage. Browser developer tools usually\n\t\t\toffer a way to view and modify local storage. TScript files are\n\t\t\tstored under keys starting with tscript.data.
\n\t\t\t
\n\t\t\tThe given event name is not known.\n\t\t\t
\n\t\t\t\n\t\t\tThe most probable reason for this error is a misspelled event name.\n\t\t\t
\n\t\t",children:[]},{id:"am-41",content:'\n\t\t\t\n\t\t\tThe function registered as an event handler is expected to take exactly\n\t\t\tone argument, the event object. A common way to declare event handlers\n\t\t\tis as follows:\n\t\t\t
\n\t\t\tThis error is raised if the event handler takes no arguments or more\n\t\t\tthan one argument.\n\t\t\t
\n\t\t',children:[]},{id:"am-42",content:"\n\t\t\t\n\t\t\tThe function deepcopy creates a deep copy of a container.\n\t\t\tIf the container holds other containers as values then they are\n\t\t\tdeep copied, too. The copied data structure must fulfill the\n\t\t\tfollowing requirements:\n\t\t\t
\n\t\t\tThe error indicates that a recursive data structure was passed\n\t\t\tto a function that cannot handle this case since it would result\n\t\t\tin an infinite recursion, as illustrated by the following example:\n\t\t\t
\n\t\t\tWhen constructing a stereo sound,\n\t\t\tthe buffer arrays of all channels (i.e., left and right channel)\n\t\t\tmust have the same size. This error indicates that the sizes differ.\n\t\t\t
\n\t\t',children:[]},{id:"am-44b",content:'\n\t\t\t\n\t\t\tWhen constructing a sound object,\n\t\t\tthe sample frequency must be within a range supported by the underlying\n\t\t\tsystem. Browsers are required to support values at least within the\n\t\t\trange 8000 to 96000.\n\t\t\t
\n\t\t',children:[]},{id:"am-44c",content:'\n\t\t\t\n\t\t\tWhen constructing a sound object,\n\t\t\tthe number of channels must be at least one. Providing an empty array\n\t\t\traises this error. There is currently no upper limit on the number of\n\t\t\tchannels, although only values of 1 (mono) and 2 (stereo) can generally\n\t\t\tbe expected to work in all environments.\n\t\t\t
\n\t\t',children:[]},{id:"am-45",content:'\n\t\t\t\t\t\t\n\t\t\t\t\t\tThe error indicates that a too large object was created.\n\t\t\t\t\t\tThis applies (in theory) to the types\n\t\t\t\t\t\tRange, Array, and Dictionary, but in practice it applies only\n\t\t\t\t\t\tto ranges. In the\n\t\t\t\t\t\tfollowing code\n\t\t\t\t\t\t
\n\t\t\t\t\t\tThe error indicates that a given resource string is invalid,\n\t\t\t\t\t\tor that the resource is of the wrong type. First of all, make\n\t\t\t\t\t\tsure that the string is a valid data URI. For example, a data\n\t\t\t\t\t\tURI encoding a JPEG image should start with\n\t\t\t\t\t\t"data:image/jpeg;base64,"
followed by\n\t\t\t\t\t\tunsystematically looking data.\n\t\t\t\t\t\t
\n\t\t\t\t\t\tBesides a broken data URI, this error can occur when providing\n\t\t\t\t\t\tan unsuitable data type. For example, creating a sound object\n\t\t\t\t\t\tfrom image data raises this error.\n\t\t\t\t\t\t
\n\t\t\t\t\t',children:[]},{id:"am-47",content:"\n\t\t\t\t\t\t\n\t\t\t\t\t\tThe error indicates that an array of the wrong size was passed\n\t\t\t\t\t\tto a function. For example, the canvas.setPixel
\n\t\t\t\t\t\tfunction expects an array of size four as its last parameter.\n\t\t\t\t\t\t
\n\t\t\t\t\t\tThis error is raised when a file is not found in an\n\t\t\t\t\t\t
\n\t\t\t\t\t\tThis error is raised when a (possibly filled or framed) circle\n\t\t\t\t\t\tis drawn on the canvas with a negative radius.\n\t\t\t\t\t\t
\n\t\t\t\t\t",children:[]},{id:"am-50",content:"\n\t\t\t\t\t\t\n\t\t\t\t\t\tThis error occurs on the attempt of initializing (constructing)\n\t\t\t\t\t\ta built-in value from itself, or from another value that is still\n\t\t\t\t\t\tin the process of being constructed. This is a very rare case.\n\t\t\t\t\t\tFor example, it occurs when instantiating an object of the\n\t\t\t\t\t\tfollowing class:\n\t\t\t\t\t\t
\n\t\tA name refers to a declaration\n\t\taccording to the name lookup rules. The errors in this category indicate\n\t\tthat something went wrong either when declaring or when resolving a name.\n\t\t
\n\t',children:[{id:"ne-1",content:'\n\t\t\t\n\t\t\tWhen providing named arguments in a function call, each parameter\n\t\t\tcan be specified only once. This error indicates that a parameter\n\t\t\twas specified multiple times. This includes the case that the\n\t\t\tparameter was specified as a positional and as a names argument.\n\t\t\t
\n\t\t\t\n\t\t',children:[]},{id:"ne-2",content:'\n\t\t\t
\n\t\t\tWhen calling a function with named parameters then the function to be\n\t\t\tcalled must have a parameter with the given name – otherwise\n\t\t\tthis error is reported.\n\t\t\t
\n\t\t\t\n\t\t\tA function cannot be called with more arguments than it has\n\t\t\tparameters. An attempt to do so results in this error.\n\t\t\t
\n\t\t\t\n\t\t\tWhen calling a function, all (non-default) parameters must be\n\t\t\tspecified by providing corresponding (positional or named)\n\t\t\targuments. Failure to specify a parameter results in this error.\n\t\t\t
\n\t\t\t\n\t\t\tThis error means that the given name cannot be resolved\n\t\t\tsince no declaration of the given name exists. The three most\n\t\t\tcommon causes of this error are\n\t\t\t
\n\t\t\tIn certain situations a name is resolved into a variable that cannot\n\t\t\tbe accessed from the current context. This error refers to the case\n\t\t\tthat the variable requires a
\n\t\t\tIn certain situations a name is resolved into a variable that cannot\n\t\t\tbe accessed from the current context. This error refers to the case\n\t\t\tthat the name refers to a local variable in an outer non-global scope.\n\t\t\t
\n\t\t\t\n\t\t\tIn certain situations a name is resolved into a variable that cannot\n\t\t\tbe accessed from the current context. This error refers to the case\n\t\t\tthat the only candidate to which the name could resolve is a private\n\t\t\tmember up a (direct or indirect) super class.\n\t\t\t
\n\t\t\t\n\t\t\t\t\t\tThis error indicates that a name refers to a namespace, while a\n\t\t\t\t\t\tdifferent entity was expected.\n\t\t\t\t\t\t
\n\t\t\t\t\t\t\n\t\t\t\t\t\tThe member access operator .\n\t\t\t\t\t\treferences a public member of a type. If the left-hand-side evaluates\n\t\t\t\t\t\tto a type then access is restricted to public static members.\n\t\t\t\t\t\tThis error is reported if neither the type nor any of its super\n\t\t\t\t\t\tclasses has a public static member of the given name.\n\t\t\t\t\t\t
\n\t\t\t\t\t',children:[]},{id:"ne-13",content:'\n\t\t\t\t\t\t\n\t\t\t\t\t\tThe member access operator .\n\t\t\t\t\t\treferences a public member of a type. This error is reported if neither\n\t\t\t\t\t\tthe type nor any of its super classes has a public member of the given\n\t\t\t\t\t\tname.\n\t\t\t\t\t\t
\n\t\t\t\t\t',children:[]},{id:"ne-14",content:"\n\t\t\t\n\t\t\tNames declared within a scope must be unique. This error indicates\n\t\t\tthat a variable name is already used by a different declaration.\n\t\t\t
\n\t\t\t\n\t\t\tIn some contexts it is not obvious which names belong to which scope.\n\t\t\tOne typical pitfall is that function parameters, closure parameters,\n\t\t\tand the function body are all in the same scope.\n\t\t\t
\n\t\t",children:[]},{id:"ne-15",content:"\n\t\t\t\n\t\t\tNames declared within a scope must be unique. This error indicates\n\t\t\tthat a function name is already used by a different declaration.\n\t\t\t
\n\t\t\t\n\t\t\tIn some contexts it is not obvious which names belong to which scope.\n\t\t\tOne typical pitfall is that function parameters, closure parameters,\n\t\t\tand the function body are all in the same scope.\n\t\t\t
\n\t\t",children:[]},{id:"ne-16",content:'\n\t\t\t\n\t\t\tNames declared within a scope must be unique. This error indicates\n\t\t\tthat a parameter name is already used by a different declaration.\n\t\t\t
\n\t\t\t\n\t\t\tIn some contexts it is not obvious which names belong to which scope.\n\t\t\tOne typical pitfall is that function parameters, closure parameters,\n\t\t\tand the function body are all in the same scope. Therefore a function\n\t\t\tparameter can conflict with a\n\t\t\tclosure\n\t\t\tparameter, which is declared first.\n\t\t\t
\n\t\t',children:[]},{id:"ne-17",content:'\n\t\t\t\n\t\t\tAll closure\n\t\t\tparameters belong to the same scope, therefore they must be unique.\n\t\t\tIf two closure parameters are declared with same name are declared\n\t\t\tthen this error is reported.\n\t\t\t
\n\t\t',children:[]},{id:"ne-18",content:"\n\t\t\t\n\t\t\tNames declared within a scope must be unique. This error indicates\n\t\t\tthat a class name is already used by a different declaration.\n\t\t\t
\n\t\t\t\n\t\t\tIn some contexts it is not obvious which names belong to which scope.\n\t\t\tOne typical pitfall is that function parameters, closure parameters,\n\t\t\tand the function body are all in the same scope.\n\t\t\t
\n\t\t",children:[]},{id:"ne-19",content:"\n\t\t\t\n\t\t\tNames declared within a scope must be unique. This error indicates\n\t\t\tthat a namespace name is already used by a different declaration.\n\t\t\t
\n\t\t\t\n\t\t\tIn some contexts it is not obvious which names belong to which scope.\n\t\t\tOne typical pitfall is that function parameters, closure parameters,\n\t\t\tand the function body are all in the same scope.\n\t\t\t
\n\t\t",children:[]},{id:"ne-21",content:'\n\t\t\t\n\t\t\tThe constructor of a class\n\t\t\tcan invoke the constructor of the super class with a special syntax\n\t\t\tstarting with a colon after the parameter list. Calling the super class\n\t\t\tconstructor makes sense only if the class has a super class. This error\n\t\t\tindicates that the super class constructor is called although there does\n\t\t\tnot exist a super class.\n\t\t\t
\n\t\t',children:[]},{id:"ne-22",content:'\n\t\t\t\n\t\t\tThe super class of a class\n\t\t\tis provided as a name. The name must refer to a type, otherwise this\n\t\t\terror is reported.\n\t\t\t
\n\t\t',children:[]},{id:"ne-23",content:'\n\t\t\t\n\t\t\tWhen importing all names from a namespace with a\n\t\t\tuse directive of the form\n\t\t\t
\n\t\t\tWhen importing a name from a namespace with a\n\t\t\tuse directive, then the\n\t\t\tnames are made available in the current scope as if the declarations\n\t\t\twere members of the scope. Since names of declarations in a scope\n\t\t\tmust be unique, this can trigger conflicts. This error indicates that\n\t\t\tthe attempt to import a name creates such a conflict, since the name\n\t\t\twas already taken by a declaration or by another name import.\n\t\t\t
\n\t\t\t\n\t\t\tThe often easiest way to fix this problem is to remove the use directive\n\t\t\tand to access the declaration by its full name. When importing a single\n\t\t\tname, a better solution is to import the conflicting declaration under\n\t\t\tan alias name.\n\t\t\t
\n\t\t',children:[]},{id:"ne-25",content:'\n\t\t\t\n\t\t\tIt was attempted to call a constructor of a type with a protected or\n\t\t\tprivate constructor from outside the scope of the class, and for a\n\t\t\tprotected constructor, from outside the scope of its sub-classes.\n\t\t\tThis violates the member access rules explained\n\t\t\there.\n\t\t\t
\n\t\t\t\n\t\t\tAn easy fix is to make the constructor public. However, this error\n\t\t\tusually indicates that objects of the given type should not ever be\n\t\t\tcreated directly from outside the class.\n\t\t\t
\n\t\t',children:[]},{id:"ne-26",content:"\n\t\t\t\n\t\t\tIt was attempted to use a class as its own super class.\n\t\t\tThat's not possible because inheritance chains must be cycle-free.\n\t\t\t
\n\t\t",children:[]},{id:"ne-28",content:'\n\t\t\t\n\t\t\tIt was attempted to use the result of an expression that can only\n\t\t\tbe resolved at runtime as a loop variable. The only variables\n\t\t\tallowed as loop counters in a for-loop are local and global\n\t\t\tvariables, possible inside of namespaces.\n\t\t\t
\n\t\t\t\n\t\t\tThis error occur if something along the following lines is\n\t\t\tattempted:\n\t\t\t
\n\t\t\t\n\t\t\tIn both cases, the reason for the failure is that the result\n\t\t\tof the expressions (like counters[0]
,\n\t\t\tcounters[1]
and a.counter
) is resolved\n\t\t\tdynamically at runtime. Dynamic name lookup is not supported by\n\t\t\tTScript for-loops.\n\t\t\t
\n\t\t\tAs a remedy, use a variable name that can be resolved statically.\n\t\t\tIdeally, loop counters should be declared inside of the for-loop\n\t\t\twith the
\n\t\t\tAlternatively, all "plain" variables accessible from the scope\n\t\t\tcontaining the loop work fine:\n\t\t\t
\n\t\t\t\n\t\t\tWhile functions and classes are subject to hoisting (i.e., their names\n\t\t\tcan be used before they are declared), variables are not. To fix this\n\t\t\terror, move the declaration of the variable before its first use.\n\t\t\t
\n\t\t",children:[]},{id:"ne-30",content:'\n\t\t\t\n\t\t\tIt was tried to access a non-static member without an object. Example:\n\t\t\t
\n\t\t\t\n\t\t\tTo fix the problem, make sure to access the member through an object\n\t\t\t(the variable a
in the above example), not through its\n\t\t\tclass (the class A
in the above example).\n\t\t\t
\n\t\t\tThis error indicates that too many function calls were nested.\n\t\t\tIt is often caused by an infinite recursion.\n\t\t\t
\n\t\t",children:[]},{id:"le-2",content:'\n\t\t\t\n\t\t\tThe function enterEventMode
was called,\n\t\t\tdirectly or indirectly, from within an event handler. Event\n\t\t\thandling mode cannot be nested, hence this error is reported.\n\t\t\t
\n\t\t\tThis error indicates that the function\n\t\t\tquitEventMode
was called although the\n\t\t\tprogram was not in event handling mode.\n\t\t\t
\n\t\t\tThe library function assert can be\n\t\t\tcalled in order to report an error in case a condition is violated.\n\t\t\tThe error is reported by user or library code, not by the core language.\n
\n\t\t\tThe library function error can be\n\t\t\tcalled in order to report an error. The error is reported by user\n\t\t\tor library code, not by the core language.\n
\n\t\t\tIf an exception is thrown\n\t\t\tand not caught then\n\t\t\tthe program stops and this error message is reported. This is often\n\t\t\tunintended by the programmer and hints at an internal error that\n\t\t\tshould be fixed.\n
\n\t\t\tThis error is reported if the indentation of a program is\n\t\t\tinconsistent. The indentation in each block must be larger\n\t\t\tthan in its surrounding block, and it must be consistent\n\t\t\twithin the block.\n\t\t\t
\n\t\t\tThis error is reported if the indentation of program block\n\t\t\tmarkers is inconsistent, i.e., if the indentation of the line\n\t\t\tcontaining an opening brace differs from the indentation of\n\t\t\tthe line with the corresponding closing brace:\n\t\t\t
\n\t\t\tThis error can occur when a variable, function, or namespace name\n\t\t\tstarts with a capital letter. By convention, these names start with\n\t\t\ta lowercase letter or an underscore.\n\t\t\t
\n\t\t\t\n\t\t\tThis error can occur when a class name starts with a\n\t\t\tlowercase letter or an underscore. By convention, TScript\n\t\t\tclass names start with a capital letter.\n\t\t\t
\n\t\t\t\n\t\t\tThis error is reported if the TScript parser fails to\n\t\t\toperate as expected. This is not the fault of the program\n\t\t\twritten by the user, but rather a bug on the side of\n\t\t\tTScript.\n\t\t\t
\n\t\t\t\n\t\t\tThis should never happen. If it does happens to you, then\n\t\t\tplease report the bug.\n\t\t\t
\n\t\t",children:[]},{id:"ie-2",content:"\n\t\t\t\n\t\t\tThis error is reported if the TScript interpreter fails to\n\t\t\toperate as expected. This is not the fault of the program\n\t\t\twritten by the user, but rather a bug on the side of\n\t\t\tTScript or its standard library.\n\t\t\t
\n\t\t\t\n\t\t\tThis should never happen. If it does happens to you, then\n\t\t\tplease report the bug.\n\t\t\t
\n\t\t",children:[]}]}]}},9295:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.doc_examples=void 0,e.doc_examples={id:"examples",name:"Example Programs",title:"Example Programs",content:'\n\t\n\tThis section provides example programs demonstrating the use of\n\tturtle and canvas graphics. They can by copied by clicking the code.\n\tSimply paste the code into the editor and run the programs. You may\n\tneed to activate the corresponding panels (turtle or canvas) in\n\torder to see the output.\n\t
\n\t\n\tTScript is not only a programming language, it also comes with a\n\tfully fledged integrated development environment (IDE). The IDE\n\tincludes a code editor and powerful debugging facilities.\n\t
\n\t\n\tIn principle, the IDE can be decoupled from the programming language,\n\tand a single IDE can be used for a multitude of languages. However,\n\tproviding a default IDE for the language has advantages for\n\tbeginners. No choices need to be made. More importantly, there is no\n\tfriction in setup and configuration processes.\n\t
\n\t\n\tThe TScript IDE main window consists of a toolbar at the top and an\n\tarea holding several panels. The panels can be docked to a wide area\n\ton the left or to a more narrow area on the right. They can also\n\tfloat around freely on top of docked panels, one panel can be\n\tmaximizied on top of all others, and panels can be reduced to icons.\n\tAll of this is controlled with the buttons in the title bar of each\n\tpanel. Panels can be resized by dragging the lower and right edges.\n\t
\n",children:[{id:"toolbar",name:"Toolbar",title:"Toolbar",content:'\n\t\t\n\t\tThe IDE has a toolbar at the top. It features a number of central\n\t\tcontrols.\n\t\t
\n\n \n
\n\t\tThe four leftmost buttons manage files (red). They create a new\n\t\tdocument, open a document from a file, save to file, and save\n\t\tunder a different name. Currently, documents can only be stored\n\t\tin the local storage of the browser.\n\t\t
\n\t\tThe next group of buttons controls program execution (green). They\n\t\tstart or continue, interrupt, and abort the program. When multiple\n\t\tdocuments are open at the same time, the dropdown box allows to\n\t\tselect the one that is to be executed.\n\t\t
\n\t\tThe buttons with the blue frame marker belong to the debugger.\n\t\tThey step through the program at different levels of granularity.\n\t\tThe button with the little red dot toggles (sets/removes) the\n\t\tbreakpoint in the current line, or the closest line below that is\n\t\ta legal breakpoint location.\n\t\t
\n\t\tThe green arrow opens the export dialog (yellow frame). It allows\n\t\tto export programs using turtle graphics or canvas graphics as\n\t\tstandalone applications (web pages). These files can be ran in a\n\t\tbrowser, i.e., independent of the TScript IDE.\n\t\t
\n\t\tThe button with the gear symbol opens the configuration dialog.\n\t\tCurrently it allows to configure the hotkeys associated with the\n\t\ttoolbar buttons. Furthermore, there is a checkbox that enables\n\t\tstyle checking mode.\n\t\t
\n\t\tIt follows a wide element with colored background, called the\n\t\tprogram state indicator. It indicates whether the program is just\n\t\tabout to be written, whether it was parsed successfully or whether\n\t\tan error occurred, and whether the program is running, waiting, or\n\t\tinterrupted.\n\t\t
\n\t\tRight of the program indicator there is an area collecting icons of\n\t\ticonified panels (purple). The icons can be clicked to restore the\n\t\tprevious non-icon state of a panel.\n\t\t
\n\t\t\n\t\tFinally, the button on the far right opens the documentation (i.e.,\n\t\tthis very collection of documents) in a new window or browser tab.\n\t\t
\n\t',children:[]},{id:"editor",name:"Source Code Editor",title:"Source Code Editor",content:'\n\t\t\n\t\tThe source code editor is the most important panel. It consists\n\t\tof a modern browser-based text editor with syntax highlighting\n\t\tfor the TScript programming language. The program code is typed,\n\t\tpasted, or loaded into this panel. Breakpoints can be toggled\n\t\t(added/removed) by clicking the bar on the left, which also\n\t\tdisplays line numbers.\n\t\t
\n\t\t\n\t\tSince longer programs usually consist of multiple files, the IDE\n\t\tsupports any number of editor panels. Creating or opening a new\n\t\tfile spawns a new editor.\n\t\t
\n\t\t\n\t\tBesides the hotkeys defined for the\n\t\ttoolbar buttons, the editor provides\n\t\tthe following hotkeys:\n\t\t
key | effect |
---|---|
control-A | select all |
control-Z | undo last change |
shift-control-Z | redo last change |
control-Home | jump to start of the document |
control-End | jump to end of the document |
Tabulator | when applied to a selection, indent the affected lines |
shift-Tabulator | un-indent the current or selected line(s) |
control-D | toggle line comment; comment/uncomment current or selected line(s) |
control-F | open the find/replace dialog |
F3 | next search result |
\n\t\tThe message area contains two types of entities: text printed by\n\t\tthe program with the print function,\n\t\tand error messages. Errors are clickable, highlighting the line\n\t\tof code in which the error occurred. Also, there is a clickable\n\t\tinformation symbol 🛈 that opens the documentation of the\n\t\terror.\n\t\t
\n\t',children:[]},{id:"debugging",name:"Debugging Facilities",title:"Debugging Facilities",content:'\n\t\t\n\t\tThe debugger is firmly integrated into the IDE. It consists of\n\t\tseveral elements. The most prominent ones are stack and program\n\t\tview. Furthermore, stepwise program execution is controlled with\n\t\tthe toolbar buttons, the message area collects error messages,\n\t\twhich are often a starting point for debugging, and breakpoints\n\t\tare defined in the source code error.\n\t\t
\n\n\t\t\n\t\tThis panel contains information only while the program is running.\n\t\tIt displays the program state as a tree. At the topmost level, the\n\t\ttree contains one node per stack frame, which is the entity holding\n\t\tall local variables of a function. The bottom-most stack frame\n\t\t(with index [0]) holds the global variables.\n\t\t
\n\t\t\n\t\tEach stack frame holds one sub-node per variable. If the variable\n\t\trefers to a container or an object, then the node can be opened and\n\t\tthe items or attributes are found in the next layer. For example,\n\t\tan array holding 10 items is represented by 10 sub-nodes, one for\n\t\teach item.\n\t\t
\n\t\t\n\t\tFurthermore, each stack frame holds a list of temporary values. A\n\t\ttemporary value exists only during the evaluation of an expression,\n\t\tbefore it is consumed by another expression.\n\t\t
\n\t\t\n\t\tThe panel allows to inspect the values of all variables at runtime.\n\t\tThis information is invaluable for debugging. While running the\n\t\tprogram step by step the programmer can monitor the effect of all\n\t\tcommands on the variables.\n\t\t
\n\n \n
\n\t\tThis panel contains information only after the program is parsed.\n\t\tIt displays the program structure as a tree. The root node\n\t\trepresents the global scope. Nodes below this one represent\n\t\tdeclarations and statements, which again have sub-nodes, all the\n\t\tway down to atomic units like literals, names, operators, etc.\n\t\tClicking a node of the tree navigates the cursor in the source code\n\t\teditor to the corresponding element. The position of the element is\n\t\tfurthermore provided in parentheses, in the form (line:character).\n\t\t
\n\t\t\n\t\tDuring runtime, the tree displays the current instruction by\n\t\thighlighting it with an orange background. It provides an\n\t\tinstructive illustration of the program flow, which can be a\n\t\tvaluable debugging aid.\n\t\t
\n\t',children:[]},{id:"program",name:"Program IO Panels",title:"Program IO Panels",content:"\n\t\t\n\t\tThere are two panels dedicated to input and output of the program:\n\t\tone for turtle graphics, and one for a proper graphical user interface.\n\t\tIt is uncommon to include these facilities directly into an IDE. This\n\t\tis because programs are supposed to run independent of the IDE. For\n\t\tTScript this is a minor concern, since the language is not designed\n\t\tfor production use.\n\t\t
\n\n\t\t\n\t\tThe turtle graphics panel represents the area in which the fictitious\n\t\tturtle robot moves around. The panel contains the lines drawn by the\n\t\trobot while moving. It does not display the turtle.\n\t\t
\n\t\t\n\t\tThe panel is automatically cleared at program start. The drawing\n\t\tremains even after the program has finished.\n\t\t
\n\t\t\n\t\tThe drawing area is a square. However, for display, the area is\n\t\tstretched along one axis to match the aspect ratio of the panel.\n\t\tTherefore it is best practice to keep the panel roughly square shaped.\n\t\t
\n\n\t\t\n\t\tThe canvas panel contains a canvas for drawing geometric shapes and\n\t\ttext. With these tools it is rather easy to display images, for\n\t\texample for simple video games. The panel allows for rich user\n\t\tinteraction. Mouse clicks and mouse pointer movement as well as key\n\t\tpresses generate events that can be processed by the program to\n\t\tcreate interactive applications.\n\t\t
\n\t",children:[]},{id:"exportdialog",name:"Export dialog",title:"Export dialog",content:"\n\t\t\n\t\tThe export dialog allows to create a standalone webpage from the current TScript code.\n\t\tIt is either a turtle application or a canvas application, that means that only one of these is shown\n\t\tin the final webpage.\n\t\t
\n\t",children:[]}]}},6142:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.documentationData=void 0;const r=n(986),i=n(5675),a=n(6083),o=n(9295),s=n(4045),l=n(8703),c=n(9521),d=n(9919),h=n(3193);let p={id:"",name:"TScript Documentation",title:"TScript Documentation",children:new Array,content:'\n\nWelcome to TScript!\n
\n\nTScript ("teaching-script") is a programming language created\nspecifically for programming beginners. Its clean design yields a smooth\nlearning experience. It offers simple graphics manipulation\nenvironments, which greatly boost motivation and stimulate a playful and\nexplorative learning style.\n
\n\nThe ideal entry point for a programming beginner is the tutorial. In the\ndevelopment environment, locate the blackboard icon\n\nin the toolbar. It opens the tutorial panel. The tutorial is not part of\nthis documentation; instead, it is tightly integrated into the\nprogramming environment.\n
\nBeing a reference documentation, this collection of documents is not\ndesigned for being read front to end, but rather as a resource for\nlooking up information. For programmers experienced with other\nprogramming languages, the section\ncore concepts is a good starting point, the\ncheat sheet provides the most\nimportant bits in compact form, and for the impatient there are a few\nexamples.\n
\n'};p.children.push(i.doc_concepts),p.children.push(s.doc_ide),p.children.push(l.doc_language),p.children.push(h.doc_stdlib),p.children.push(o.doc_examples),p.children.push(a.doc_errors),p.children.push(c.doc_data_uri),p.children.push(r.doc_cheatsheet),p.children.push(d.doc_legal),e.documentationData=p},8703:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.doc_language=void 0,e.doc_language={id:"language",name:"The TScript Language",title:"Reference Documentation for the TScript Programming Language",content:"\n\t\n\tThis is the reference documentation of the TScript programming\n\tlanguage. It covers all language features in great detail and with\n\tprecision.\n\t
\n",children:[{id:"syntax",name:"Syntax",title:"Syntax",content:'\n\t\t\n\t\tThe syntax of the TScript language specifies whether a text is\n\t\ta well-formed (valid) or ill-formed (invalid) program. A\n\t\twell-formed program can be executed, while trying to run\n\t\tan ill-formed (or malformed) program results in an error\n\t\tmessage already before the program starts. The syntax is\n\t\tspecified in terms of an\n\t\tExtended Backus-Naur Form (EBNF).\n\t\t
\n\t\t\n\t\tThe documents within this section define various general aspects\n\t\tof the TScript syntax. For completeness sake, we also provide a\n\t\tcomplete formal EBNF definition of the TScript syntax.\n\t\t
\n\t',children:[{id:"character-set",name:"Character Set",title:"Character Set",content:'\n\t\t\t\n\t\t\tTScript source code consists of unicode characters from the\n\t\t\tBasic Multilingual Plane (BMP).\n\t\t\tThese characters have codes in the range U+0000 to U+FFFF.\n\t\t\tIn other words, each character (or "code point") can be\n\t\t\trepresented as an unsigned 16-bit integer.\n\t\t\t
\n\t\t\t\n\t\t\tHowever, this document does not specify the character\n\t\t\tencoding, but only the character set. So for\n\t\t\texample UTF-8 encoded text is fine, as long as it does not\n\t\t\tcontain code points above U+FFFF.\n\t\t\t
\n\t\t\t\n\t\t\tOutside of\n\t\t\tcomments and\n\t\t\tstring literals,\n\t\t\tonly the printable ASCII range U+0020 to U+007E and the\n\t\t\tASCII control characters U+0009 (horizontal tabulator),\n\t\t\tU+000A (line feed), and U+000D (carriage return) are valid.\n\t\t\t
\n\t\t\t\n\t\t\tInside comments and string literals, the full range U+0000\n\t\t\tto U+FFFF is legal. Every character can be denoted in plain\n\t\t\tASCII by means of an escaping mechanism.\n\t\t\t
\n\t\t\t\n\t\t\tNote:\n\t\t\tThe TScript implementation is based directly on Javascript\n\t\t\t(ECMAScript 6). Javascript allows its implementations\n\t\t\tto support the complete unicode range by composing\n\t\t\tcharacters outside the BMP with the UTF16 encoding, but this\n\t\t\tfeature is not mandatory. In practice, Javascript engines do\n\t\t\tsupport the mechanism, which amounts to representing the\n\t\t\tunicode characters outside the BMP with two characters in\n\t\t\tthe range U+0000 to U+FFFF. This solution is error-prone.\n\t\t\tFor example, it is somewhat surprising if a string that\n\t\t\tprints as a single character consists of two characters, as\n\t\t\trevealed by the size method and when accessing the\n\t\t\tcharacters, slicing the string, etc. It is therefore\n\t\t\trecommended to restrict string contents to the BMP.\n\t\t\t
\n\t\t',children:[]},{id:"tokens",name:"Tokens",title:"Tokens",content:'\n\t\t\t\n\t\t\tA TScript program consists of a sequence of tokens. Each\n\t\t\ttoken is a meaningful and often short string of characters\n\t\t\twith clear semantics. Tokens can be separated by whitespace,\n\t\t\tcomments, other terminals, or they can be self-delimiting.\n\t\t\tA sequence of input characters that does not match any of\n\t\t\tthe token types results in a syntax error. In this documentation\n the red-written expressions need to be replaced by the corresponding\n tokens. The "|" denote the logical or, "()" enclose connected tokens.\n "[]" express that the inner expressions are optional and therefore can\n be chosen zero or one times, "{}" express that the inner expressions can\n be chosen zero or n times.\n\t\t\t
\n\n\t\t\t\n\t\t\tWhitespace and\n\t\t\tcomments are not\n\t\t\tby themselves considered tokens, but they separate tokens\n\t\t\tand therefore they must be defined:\n\t\t\t
\n\t\t\tAn identifier is defined as follows:\n\t\t\t
\n\t\t\tAn integer is simply defined as a non-empty sequence of\n\t\t\tdigits:\n\t\t\t
\n\t\t\tA real must contain a fractional part, or an exponent, or both:\n\t\t\t
\n\t\t\tSimple strings are character sequences enclosed in double\n\t\t\tquotes. A string token can contain escape sequences. It is\n\t\t\tdefined as follows:\n\t\t\t
\n\t\t\tFor these simple token types, we let the definition speak\n\t\t\tfor itself. Note that some operators start with a shorter\n\t\t\tsequence that also forms an operator. The token is always\n\t\t\tthe longest possible sequence.\n\t\t\t
\n\t\t\t\n\t\t\tCertain identifier names are disallowed, namely the\n\t\t\tso-called keywords. Here is a complete list of all TScript\n\t\t\tkeywords in alphabetical order:\n\t\t\t
\n\t\t\t\n\t\t\tNot all keywords are used in the current version of the language,\n\t\t\tsome are reserved for future extensions.\n\t\t\t
\n\t\t",children:[]},{id:"comments",name:"Comments",title:"Line and Block Comments",content:'\n\t\t\t\n\t\t\tComments are pieces of program code without any semantic\n\t\t\tmeaning. In other words, comments are ignored when running\n\t\t\tthe program. While being ignored by the machine, they are\n\t\t\tintended to be read by humans, usually for the purpose of\n\t\t\tdocumentation. In TScript there are two types of comments:\n\t\t\tline comments and block comments.\n\t\t\t
\n\t\t\t\n\t\t\tLine comments start with the token\n\t\t\t#
not immediately followed by\n\t\t\t*
and extend to the end of the\n\t\t\tline. One beneficial property of line comments is that they\n\t\t\tcan be nested, i.e.,\n\t\t\t
\n\t\t\tBlock comments start with #*
and end with\n\t\t\t*#
. In contrast to line comments, block\n\t\t\tcomments are entirely free in their extent. They may span\n\t\t\tonly a small part of a line or even multiple lines. The price to pay is that\n\t\t\tblock comments cannot be nested, since in\n\t\t\t
#* a broken #* block *# comment *#
*#
, so that comment *
is\n\t\t\tinterpreted as program code (which is most probably malformed),\n\t\t\tand the final #
as the start of a\n\t\t\tline comment.\n\t\t\t\n\t\t',children:[]},{id:"lexical-blocks",name:"Lexical Blocks and Separators",title:"Lexical Blocks and Separators",content:'\n\t\t\t\n\t\t\tIn TScript, whitespace is useful for separating tokens, but\n\t\t\tit is insignificant for separating language constructs like\n\t\t\tdefinitions, statements, and directives. In particular,\n\t\t\tindentation is optional, and statements can extend beyond\n\t\t\tthe end of the current line. Instead, declarations and\n\t\t\tstatements are delimited by keywords and, in most cases,\n\t\t\twith a semicolon
\n\t\t\tAnother useful structural property of the TScript language that\n\t\t\tbecomes apparent already at the lexical level are parentheses\n\t\t\t( )
, square brackets [ ]
,\n\t\t\tand curly braces { }
. The TScript syntax\n\t\t\tis designed so that opening and closing tokens must always match.\n\t\t\tFor example, when encountering the sequence of tokens\n\t\t\t{(
then )
is fine, while\n\t\t\tencountering }
first indicates a syntax error.\n\t\t\t
\n\t\t\tThis section collects all syntax rules for reference.\n\t\t\t
\n\n\t\t\t\n\t\tA declaration defines a named entity. Possible entities are variables,\n\t\tfunctions, classes, and namespaces. Hence, a declaration is defined\n\t\tformally as follows:\n\t\t
\n\t\t\tA variable is a named entity referencing a value.\n\t\t\t
\n\n\t\t\t\n\t\t\tVariables are declared with following syntax:\n\t\t\t
\n\t\t\tAt each time, a variable references exactly one value. Variables\n\t\t\tare untyped; they can refer to a values of any type, and the type\n\t\t\tcan change during runtime.\n a
\n\t\t\tin the above example), then it is implicitly set to\n\t\t\t
\n\t\t\tMultiple variables can refer to the same value.\n\t\t\tAssigning a value\n\t\t\tto a variable only references the value, it does not copy the value.\n\t\t\tIt is different from initialization, and the variable itself may\n\t\t\tappear on the right hand side, referring to the old value before\n\t\t\tthe actual assignment takes place:\n\t\t\t
\n\t\t\tParameters of functions are also variables, although they are\n\t\t\tdeclared without
\n\t\t\tVariables inside classes are called attributes. These variables\n\t\t\tcan be initialized, but the initializer must evaluate to a\n\t\t\tconstant. Variable that should be initialized to a value\n\t\t\tcomputed at runtime can be set in the constructor.\n
\n\t\t\tClosure parameters are somewhere in between the above two cases.\n\t\t\tThey are stored inside the function closure like attributes in\n\t\t\tan object. Whenever the closure is called they are copied, and\n\t\t\tthe copies become parameters of the function.\n\t\t\t
\n\n\t\t\t\n\t\t\tTScript distinguishes three types of variables:\n\t\t\t
\n\t\t\tA function is a named block of code that can be invoked arbitrarily\n\t\t\toften, possibly with different parameter values.\n\t\t\t
\n\n\t\t\t\n\t\t\tFunctions are declared with the following syntax:\n\t\t\t
\n\t\t\tParameters of functions are always named, with an optional default value.\n\t\t\tAs can be seen in the above example, function names are valid expressions\n\t\t\t(of type Function).\n\t\t\t
\n\t\t\t\n\t\t\tAn alternative way to define functions are\n\t\t\tanonymous\n\t\t\tfunctions.\n\t\t\t
\n\t\t',children:[]},{id:"classes",name:"Classes",title:"Classes",content:'\n\t\t\t\n\t\t\tA class declaration adds a new type to the program. Values or objects\n\t\t\tof this type can be instantiated by calling the type like a function.\n\t\t\t
\n\n\t\t\t\n\t\t\tA class is declared with the following syntax:\n\t\t\t
\n\t\t\tThe constructor of a class is called whenever the class is instantiated,\n\t\t\ti.e., when a new object of that very class is created. Its role is to\n\t\t\tinitialize the object\'s state, comprised by its attributes. Attributes\n\t\t\tcan equally well be declared with a constant initializer. Non-constant\n\t\t\t(parameter-dependent) initialization is done in the constructor.\n\t\t\tOf course, the constructor can perform further tasks. Uninitialized\n\t\t\tmembers hold the value
\n\t\t\tClasses with a public constructor can be instantiated from everywhere,\n\t\t\tand the same holds for classes without constructor (which implies the\n\t\t\tgeneration of a public default constructor). Constructors can also be\n\t\t\tprotected or private. A class with private constructor can be\n\t\t\tinstantiated only from within a method of the class, and the class\n\t\t\tcannot have sub-classes. A class with protected constructor can have\n\t\t\tsub-classes, since the constructor can be called from a sub-class\n\t\t\tconstructor.\n\t\t\t
\n\n\t\t\t\n\t\t\tDeclarations inside the function body as known as members of the class.\n\t\t\tMembers can be declared
\n\t\t\tA public member of a class is referenced with the dot-operator, as seen\n\t\t\tin the example above. Inside the class, its members can be accessed by\n\t\t\ttheir names. The object itself, i.e., the left-hand-side of the\n\t\t\tdot operator,\n\t\t\tis available under the name
\n\t\t\tMember name lookup of the form a.numberOfInstances
\n\t\t\tin the above code happens dynamically at runtime. The result of the\n\t\t\tmember access (and\n\t\t\ttherefore, in this context, the invoked function) depends on the type\n\t\t\tof the left-hand-side, provided that multiple classes declare a member\n\t\t\tof the same name. This is an elegant mechanism for creating implicit\n\t\t\tswitches in code based on the type of data it encounters. Referencing\n\t\t\ta member name that does not exist in the type (more precisely, in its\n\t\t\tpublic interface) results in an error message.\n\t\t\t
\n\t\t\tTScript classes allow for proper information hiding, i.e., they can\n\t\t\thide implementation details behind a public or protected interface. From\n\t\t\toutside the class, only members declared
\n\t\t\tAlso inside classes, the general principle that declarations can be\n\t\t\tused only after they were declared is applied. Therefore it is common\n\t\t\tpractice to declare attributes towards the beginning of the class, so\n\t\t\tthat they can be accessed by methods declared below them.\n\t\t\t
\n\t\t\t\n\t\t\tHiding information is not always necessary, and sometimes\n\t\t\tover-complicates matters. In some cases simple classes consisting\n\t\t\tonly of public attributes are a meaningful choice. For example, the\n\t\t\tfollowing class may represent a point in a two-dimensional coordinate\n\t\t\tsystem:\n\t\t\t[x,y]
or a dictionary\n\t\t\t{"x":x,"y":y}
, but the class has the\n\t\t\tadvantages of making the role of the type and of its members explicit.\n\t\t\tThis makes code more readable and more maintainable. Furthermore it\n\t\t\tadds the ability of code to test for its the data type to clarify the\n\t\t\trole of a value, which is not possible with generic containers since\n\t\t\tthey are used for many purposes.\n\t\t\t
\n\t\t\tA class can be based on any other type, including all the\n\t\t\tbuilt-in types (however, note that\n\t\t\taggregation is often preferable over inheriting an immutable type).\n\t\t\tThis means that the type, also known as the sub-class in this context,\n\t\t\tinherits all properties and members from its super-class.\n\t\t\t
\n\t\t\t\n\t\t\tSubclassing is a common mechanism for extending the functionality of\n\t\t\ta type, and for creating a set of types with a uniform interface.\n\t\t\tThe mechanism allows to override (generic) functionality of the base\n\t\t\tor super class with (specialized) functionality of the sub-class,\n\t\t\tsimply by declaring a method of the same name as in the super class.\n\t\t\tThis does not create a name conflict. When invoking such a method on\n\t\t\tan object of the sub-class then the dispatching rules dictate that the\n\t\t\tmethod declared in the sub-class is invoked, and the method in the\n\t\t\tsuper class is ignored.\n\t\t\t
\n\t\t\t\n\t\t\tWhen implementing sub-classes, there regularly is the demand to access\n\t\t\ta super-class member of the same name or the super class constructor.\n\t\t\tThis can be achieved with a special syntax for the constructor and for\n\t\t\tnames based on the
\n\t\t\tA namespace is a named scope designed to organize declarations.\n\t\t\t
\n\n\t\t\t\n\t\t\t
\n\t\t\tNamespaces allow to keep globally accessible names out of the global\n\t\t\tscope. For large collections of declarations this greatly reduces the\n\t\t\tchance of name collisions. This is particularly important when working\n\t\t\twith large software libraries.\n\t\t\t
\n\t\t\t\n\t\t\tAs a price, the full names of declarations get longer, since the\n\t\t\tnamespace name is prepended to the declared name, separated with a dot.\n\t\t\tThis is not necessarily an issue since individual names and even whole\n\t\t\tnamespaces can be imported into\n\t\t\tthe scopes where they are used. Since import is usually selective, name\n\t\t\tcollisions are still rate.\n\t\t\t
\n\t\t',children:[]}]},{id:"directives",name:"Directives",title:"Directives",content:'\n\t\t\n\t\tA directive is an instruction to the TScript language that is\n\t\tnot directly related to the program flow itself. It is neither a\n\t\tdeclaration nor a statement.\n\t\t
\n\t\t\tA
\n\t\t\tA c
\n\t\t\tis used when importing the name a.b.c
.\n\t\t\tIf
\n\t\tAn expression is a computation that produces a value. The simplest atomic\n\t\texpressions are constants and names referring to declarations. Expressions\n\t\tcan be combined by means of operators into more complex expressions.\n\t\t
\n\n\t\t\n\t\tHere we list groups of expression types, which are further differentiated\n\t\tin a number of sub-sections.\n\t\t
\n\t\tSome expressions have side effects. A side effect is defined as an effect\n\t\tthat is unrelated to the computation of the expression result. In many\n\t\tcases, the only purpose of evaluating such expressions is to invoke the\n\t\tside effects. A simple example is the\n\t\tprint function:\n\t\tit prints its argument as a side effect and return
\n\t\tTScript knows five types of atomic literals. From these,\n\t\tcontainer-valued composite literals can be created. In addition,\n\t\tlambda functions are considered a special type of literal:\n\t\t
\n\t\t\t\tThere is only one value of type\n\t\t\t\tNull,\n\t\t\t\tdenoted by the keyword
\n\t\t\t\tThe Boolean type represent the\n\t\t\t\tlogical values
\n\t\t\t\tAn Integer literal represents a constant of type\n\t\t\t\tInteger. It is denoted by\n\t\t\t\tan integer token.\n\t\t\t\tThe value must lie in the integer range, i.e., it must not exceed\n\t\t\t\t231 - 1 = 2147483647.\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\tA Real literal represents a constant of type\n\t\t\t\tReal. It is denoted by a\n\t\t\t\treal token.\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\tThere is no syntax for denoting the special IEEE floating point\n\t\t\t\tvalues INF (infinity) and NaN (not a number) as literals. Instead\n\t\t\t\tthe functions Real.inf() and\n\t\t\t\tReal.nan() can be used to create such\n\t\t\t\tliterals. The methods Real.isFinite(),\n\t\t\t\tReal.isInfinite(), and\n\t\t\t\tReal.isNan() test for degenerate values.\n\t\t\t\tReal numbers that exceed the range specified in the\n\t\t\t\tIEEE 754 standard\n\t\t\t\toverflow to positive or negative infinity, or underflow to zero.\n\t\t\t\t
\n\t\t\t\tA String\n\t\t\t\tliteral consists of a sequence of\n\t\t\t\tstring tokens,\n\t\t\t\teach of which is text enclosed in double quotes within a\n\t\t\t\tsingle line of code. String tokens must be separated only\n\t\t\t\tby whitespace including newlines, and comments.\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\tEvery\n\t\t\t\tcharacter\n\t\t\t\tin between the double quotes is a part of the text\n\t\t\t\tbelonging to the string literal, with one exception: the\n\t\t\t\tbackslash \'\\\' acts as a so-called escape character. This\n\t\t\t\tcharacter introduces an escape sequence with a special\n\t\t\t\tmeaning, as follows:\n\t\t\t\t
\n\t\t\t\t\\\\
represents a single backslash (ASCII 92)\\"
represents double quotes (ASCII 34)\\t
represents a horizontal tabulator (ASCII 9)\\r
represents a carriage return (ASCII 13)\\n
represents a line feed (ASCII 10)\\f
represents a form feed (ASCII 12)\\b
represents a backspace (ASCII 8)\\/
represents a slash (ASCII 47)\\uXXXX
represents any Unicode character, where XXXX is the 4-digit hexadecimal code of the character (or code point)Array\n\t\t\t\tliterals are comma-separated sequences of expressions enclosed\n\t\t\t\tin square brackets. The results of evaluating the expressions\n\t\t\t\tbecome the items of the array literal:\n\t\t\t\t
\n \n
\n\t\t\t\tIf all items are constants, then the whole array is a constant.\n\t\t\t\t
\n\t\t\t',children:[]},{id:"dictionaries",name:"Dictionary Literals",title:"Dictionary Literals",content:'\n\t\t\t\tDictionary\n\t\t\t\tliterals are comma-separated sequences of key-value pairs enclosed\n\t\t\t\tin curly braces. A key-value pair consists of a key, which is either\n\t\t\t\ta string or an identifier, and a value, which is the result of an\n\t\t\t\tarbitrary expression:\n\t\t\t\t
\n\t\t\t\tNote that not all keys can be represented with the identifier\n\t\t\t\tshort-notation, simply because they are not valid identifiers. Also\n\t\t\t\tnote that this means that string variables cannot act as keys in\n\t\t\t\tstring literals; this can be achieved with the\n\t\t\t\titem access operator.\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\tIf all values are constants, then the whole dictionary is a constant.\n\t\t\t\t
\n\t\t\t',children:[]},{id:"anonymous-functions",name:"Anonymous Functions",title:"Anonymous Functions",content:'\n\t\t\t\t\n\t\t\t\tAn anonymous function or lambda function follows the syntax:\n\t\t\t\t
\n\t\t\t\tAnonymous functions can enclose variables from their surrounding scopes,\n\t\t\t\twhich are stored in the function object. In fact, the result of arbitrary\n\t\t\t\texpressions can be stored. These expressions are evaluated when the\n\t\t\t\tanonymous function is created. They are available from inside the\n\t\t\t\tfunction body when the function is invoked, which can be at a later time\n\t\t\t\tand, importantly, from a different scope. In the following (somewhat\n\t\t\t\tcontrived) example, the variable square
is not\n\t\t\t\taccessible from the global scope where lambda
\n\t\t\t\tis defined, yet the variable is available inside the anonymous function\n\t\t\t\tbecause its value is enclosed in the function as a closure parameter.\n\t\t\t\t
\n\t\t\t\tThe abilities of anonymous functions to be declared in-place as an\n\t\t\t\texpression and to enclose values from a surrounding scope are\n\t\t\t\tparticularly well-suited for callbacks.\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\tLambda functions do not have a name, therefore they cannot be referred\n\t\t\t\tto by name. This is a problem when writing recursive algorithms, since\n\t\t\t\tthe function must be able to call itself. To allow for recursion, the\n\t\t\t\t
\n\t\t\t\tNote that writing the else-case as\n\t\t\t\telse return n * fac(n-1);
does not work\n\t\t\t\tbecause fac
is a variable that cannot be\n\t\t\t\tused until it is fully initialized, and the else-statement is part\n\t\t\t\tof the initializer.\n\t\t\t\t
\n\t\t\t\tWhen invoking a lambda function, all closure variables are\n\t\t\t\tcopied into the local frame. Hence, any modification of a\n\t\t\t\tclosure variable is limited to the duration of the function\n\t\t\t\texecution.\n\t\t\t\t
\n\t\t\t',children:[]}]},{id:"unary-operators",name:"Unary Operators",title:"Unary Operators",content:"\n\t\t\t\n\t\t\tThere are three unary operators, all of which are left-unary operators\n\t\t\tbinding to an argument on their right-hand side.\n\t\t\t
\n\t\t",children:[{id:"not",name:"Logical or Bitwise Negation",title:"Logical or Bitwise Negation",content:'\n\t\t\t\t\n\t\t\t\toperator not
performs a logical or bitwise\n\t\t\t\tnegation of its argument. For
\n\t\t\t\tNote: For an integer x, (not x)
is\n\t\t\t\tequivalent to (-1 - x)
.\n\t\t\t\t
\n\t\t\t\tThe unary operator +
represents "no sign\n\t\t\t\tchange". In other words, it returns its argument unaltered.\n\t\t\t\tWhen applied to a non-numeric argument, i.e., a value that is neither\n\t\t\t\tan integer Integer nor a\n\t\t\t\tReal, the operator reports an\n\t\t\t\terror.\n\t\t\t\t
\n\t\t\t\tThe unary operator -
represents algebraic\n\t\t\t\tnegation, which is a change of sign; it returns "minus" its argument.\n\t\t\t\tWhen applied to a non-numeric argument, i.e., a value that is neither\n\t\t\t\tan integer Integer nor a\n\t\t\t\tReal, the operator reports an\n\t\t\t\terror.\n\t\t\t\t
\n\t\t\t\tWhen applied to an Integer,\n\t\t\t\tthen the operator is subject to integer overflow. Overflow happens\n\t\t\t\tonly in a single case:\n\t\t\t\t
\n\t\t\tTScript defines a total of 17 binary operators. There are seven\n\t\t\tarithmetic operators, six comparison operators, three logical\n\t\t\toperators, and the range operator.\n\t\t\t
\n\t\t",children:[{id:"addition",name:"Addition",title:"Addition",content:'\n\t\t\t\t\n\t\t\t\tThe binary operator +
returns the sum of\n\t\t\t\tits arguments. If at least one argument is a string, then the\n\t\t\t\tconcatenation of the arguments converted to strings.\n\t\t\t\tIf one of its arguments is non-numeric, i.e., a value that is neither\n\t\t\t\tan integer Integer nor a\n\t\t\t\tReal, and if not at least one of\n\t\t\t\tthe arguments is a String,\n\t\t\t\tthen the operator reports an error.\n\t\t\t\t
\n\t\t\t\tTwo integers are added as integers, and two reals are added as\n\t\t\t\treals. Mixed cases are always treated as reals. This means that\n\t\t\t\tonly in the first case the result is an integer. The corresponding\n\t\t\t\toverflow rules apply.\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\tFor string concatenation, a non-string arguments is first converted\n\t\t\t\tto a string with the String\n\t\t\t\tconstructor. For core types like booleans, numeric types, array\n\t\t\t\tand dictionary containers and ranges this usually gives the desired\n\t\t\t\tresult.\n\t\t\t\t
\n\n\t\t\t\tThe binary operator -
returns the\n\t\t\t\tdifference between its arguments.\n\t\t\t\tIf one of its arguments is non-numeric, i.e., a value that is neither\n\t\t\t\tan integer Integer nor a\n\t\t\t\tReal, then the operator reports\n\t\t\t\tan error.\n\t\t\t\t
\n\t\t\t\tTwo integers are subtracted as integers, and two reals are subtracted\n\t\t\t\tas reals. Mixed cases are always treated as reals. This means that\n\t\t\t\tonly in the first case the result is an integer. The corresponding\n\t\t\t\toverflow rules apply.\n\t\t\t\t
\n\n\t\t\t\tThe binary operator *
returns the\n\t\t\t\tproduct of its arguments.\n\t\t\t\tIf one of its arguments is non-numeric, i.e., a value that is neither\n\t\t\t\tan integer Integer nor a\n\t\t\t\tReal, then the operator reports\n\t\t\t\tan error.\n\t\t\t\t
\n\t\t\t\tTwo integers are multiplied as integers, and two reals are multiplied\n\t\t\t\tas reals. Mixed cases are always treated as reals. This means that\n\t\t\t\tonly in the first case the result is an integer. The corresponding\n\t\t\t\toverflow rules apply.\n\t\t\t\t
\n\n\t\t\t\tThe binary operator /
returns the\n\t\t\t\tquotient of its arguments.\n\t\t\t\tIf one of its arguments is non-numeric, i.e., a value that is neither\n\t\t\t\tan integer Integer nor a\n\t\t\t\tReal, then the operator reports\n\t\t\t\tan error.\n\t\t\t\t
\n\t\t\t\tThe arguments are always treated as reals. This means that the result\n\t\t\t\tis always a real, which can have a fractional part.\n\t\t\t\t
\n\n\t\t\t\tThe binary operator //
returns the\n\t\t\t\tquotient of its arguments, rounded down to the nearest integer.\n\t\t\t\tIf one of its arguments is non-numeric, i.e., a value that is neither\n\t\t\t\tan integer Integer nor a\n\t\t\t\tReal, then the operator reports\n\t\t\t\tan error.\n\t\t\t\t
\n\t\t\t\tIf both arguments are integers then the result of the division is an\n\t\t\t\tinteger. Integer division overflows only in a single case:\n\t\t\t\t
\n\t\t\t\tThe binary operator %
returns the\n\t\t\t\tremainder of the\n\t\t\t\tinteger division\n\t\t\t\tof its arguments:\n\t\t\t\t a % b = a - (a // b) * b
\n\t\t\t\tIf one of the arguments is non-numeric, i.e., a value that is neither\n\t\t\t\tan integer Integer nor a\n\t\t\t\tReal, then the operator reports\n\t\t\t\tan error.\n\t\t\t\t
\n\t\t\t\tIf both arguments are integers then the result is an integer,\n\t\t\t\totherwise the operation is carried out in floating point\n\t\t\t\tarithmetics and the result is real. The result of the modulo\n\t\t\t\toperation is always in the range
\n\t\t\t\t 0 <= a % b < math.abs(b)
\n\t\t\t\t
\n\t\t\t\tThe binary operator ^
returns its\n\t\t\t\tleft argument to the power of its right arguments.\n\t\t\t\tIf one of its arguments is non-numeric, i.e., a value that is neither\n\t\t\t\tan integer Integer nor a\n\t\t\t\tReal, then the operator reports\n\t\t\t\tan error.\n\t\t\t\t
\n\t\t\t\tIf both arguments are integers and the right-hand-side is non-negative,\n\t\t\t\tthen the operation is performed with integer arithmetics. All other\n\t\t\t\tcases are treated as reals. This means that only in the first case the\n\t\t\t\tresult is an integer. The corresponding overflow rules apply.\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\tThis behavior may not always be desired. The function\n\t\t\t\tmath.pow performs the same operation, but it always\n\t\t\t\tapplies floating point arithmetics.\n\t\t\t\t
\n\n\t\t\t\tTwo values can be compared for equality with\n\t\t\t\toperator ==
. Given two arbitrary values, the\n\t\t\t\toperator returns a Boolean.\n\t\t\t\tEquivalently, operator !=
checks for inequality.\n\t\t\t\ta != b
is equivalent to\n\t\t\t\tnot a == b
.\n\t\t\t\t
\n\t\t\t\tThe definition of value equality depends on the type. For built-in atomic\n\t\t\t\ttypes like boolean, integers, reals and strings, two values are equal if\n\t\t\t\tthey are of the same type and they hold the same boolean, number or string.\n\t\t\t\tIn particular the integer 2
and the real number\n\t\t\t\t2.0
compare equal, but they differ from the\n\t\t\t\tstring "2"
.\n\t\t\t\t
\n\t\t\t\tContainers are considered equal if they are of the same type and all of\n\t\t\t\ttheir keys and items are equal. Care must be taken to avoid recursive\n\t\t\t\treferences, see below.\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\tRanges are equal if begin and end are equal numbers. Types compare equal\n\t\t\t\tonly if they represent the same built-in type or class. Functions compare\n\t\t\t\tequal if calling them invokes the same TScript code. For methods, the\n\t\t\t\tobject must agree in addition, and for closures, all enclosed parameters\n\t\t\t\tmust compare equal.\n\t\t\t\t
\n\t\t\t\t\n\t\t\t\tThere is currently no meaningful way to compare objects, even within the\n\t\t\t\tsame class. Therefore all objects are considered different, and the check\n\t\t\t\tfor equality coincides with the check for identity performed by the\n\t\t\t\tstandard library function same. Classes that inherit the\n\t\t\t\tbuilt-in types are compares like these, while their attributes are\n\t\t\t\tignored.\n\t\t\t\t
\n\n\t\t\t\tWarning: Comparing recursively defined containers results in an infinite\n\t\t\t\trecursion of the comparison! See the following example:\n\t\t\t\t
\n\t\t\t\tTwo values can be compared for order with\n\t\t\t\toperator <
. Given two arbitrary values, the\n\t\t\t\toperator returns a Boolean if the\n\t\t\t\tvalues can be ordered. Otherwise it reports an error.\n\t\t\t\tEquivalently, operator <=
,\n\t\t\t\toperator >
, and\n\t\t\t\toperator >=
can be used to compare for order,\n\t\t\t\twith the following identity:\n\t\t\t\ta < b
is equivalent to\n\t\t\t\tnot b <= a
,\n\t\t\t\tb > a
, and\n\t\t\t\tnot a >= b
.\n\t\t\t\t
\n\t\t\t\tThe definition of value order depends on the type. Booleans cannot be\n\t\t\t\tordered. Numbers (integers and reals) are ordered in the usual way.\n\t\t\t\tStrings and arrays are ordered\n\t\t\t\tlexicographically.\n\t\t\t\tDictionaries, functions, ranges, types, and classes cannot be ordered.\n\t\t\t\t
\n\n\t\t\t\t\n\t\t\t\tWarning: Comparing recursively defined arrays results in an infinite\n\t\t\t\trecursion of the comparison! See the following example:\n\t\t\t\t
\n\t\t\t\tThe binary operator and
returns the\n\t\t\t\tlogical or bitwise conjunction of its arguments. Both arguments\n\t\t\t\tmust be Booleans or\n\t\t\t\tIntegers, otherwise\n\t\t\t\tthe operator reports an error. The result is defined as follows:\n\t\t\t\t
or | false | true |
---|---|---|
false | false | false |
true | false | true |
\n\t\t\t\tNote: The operator does not implement so-called short-circuit\n\t\t\t\tbehavior! I.e., in the code\n\t\t\t\ttest
is called, although it can be\n\t\t\t\tdecided based on the left operand of and
that the\n\t\t\t\texpression evaluates to false. Hence, the print statement inside\n\t\t\t\tof the function is executed. That may be surprising for\n\t\t\t\texperienced programmers who got used to short-circuit behavior.\n\t\t\t\t
\n\t\t\t\tThe binary operator or
returns the\n\t\t\t\t(non-exclusive) logical or bitwise disjunction of its arguments.\n\t\t\t\tBoth arguments must be\n\t\t\t\tBooleans or\n\t\t\t\tIntegers, otherwise\n\t\t\t\tthe operator reports an error. The result is defined as follows:\n\t\t\t\t
or | false | true |
---|---|---|
false | false | true |
true | true | true |
\n\t\t\t\tNote: The operator does not implement so-called short-circuit\n\t\t\t\tbehavior! I.e., in the code\n\t\t\t\ttest
is called, although it can be\n\t\t\t\tdecided based on the left operand of or
that the\n\t\t\t\texpression evaluates to true. Hence, the print statement inside\n\t\t\t\tof the function is executed. That may be surprising for\n\t\t\t\texperienced programmers who got used to short-circuit behavior.\n\t\t\t\t
\n\t\t\t\tThe binary operator xor
returns the\n\t\t\t\texclusive logical or bitwise disjunction of its arguments. Both\n\t\t\t\targuments must be Booleans\n\t\t\t\tor Integers, otherwise\n\t\t\t\tthe operator reports an error. The result is defined as follows:\n\t\t\t\t
xor | false | true |
---|---|---|
false | false | true |
true | true | false |
\n\t\t\t\tNote: For booleans, the operator is equivalent to\n\t\t\t\toperator !=
.\n\t\t\t\t
\n\t\t\t\tThe binary operator :
constructs a\n\t\t\t\tRange from its arguments.\n\t\t\t\tBoth arguments must be integers, or reals with equivalent values,\n\t\t\t\totherwise the operator reports an error. The left-hand-side becomes\n\t\t\t\tthe begin of the range, the right-hand-side becomes the end.\n\t\t\t\tApplying the operator is equivalent to passing the arguments to\n\t\t\t\tthe Range constructor.\n\t\t\t\t
\n\t\t\tA function call is an expression with the following syntax:\n\t\t\t
\n\t\t\tThe effect of the call is that a new stack frame is created with\n\t\t\tone local variable per parameter. These parameter variables are\n\t\t\tinitialized to the values of the arguments. Then the control flow\n\t\t\tcontinues at the beginning of the function body. After the function\n\t\t\treturns, either by means of an explicit\n\t\t\treturn statement or when\n\t\t\treaching the end of its body, the return value becomes the value\n\t\t\tof the function call expression, the stack frame is removed, and\n\t\t\tthe program continues in the original frame.\n\t\t\t
\n\n\t\t\t\n\t\t\tIn simple cases there is exactly one argument for each parameter\n\t\t\tof the function. The matting between arguments are parameters is\n\t\t\tdetermined by their order. Such arguments are called positional\n\t\t\targuments.\n\t\t\t
\n\t\t\t\n\t\t\tIf a parameter of a function specifies a default value then the\n\t\t\tcorresponding argument can be dropped. A neat way of providing\n\t\t\tvalues only for some parameters is to use named arguments,\n\t\t\ti.e., arguments with
\n\t\t\tAn item access is an expression with the following syntax:\n\t\t\t
\n\t\t\tThe result of an item access depends on the base type and\n\t\t\ton the key type as follows:\n\t\t\t
\n\t\t\tA member access is an expression with the following syntax:\n\t\t\t
\n\t\t\tThe member access operator cannot be used to access private\n\t\t\tand protected members. This does not even work inside of a\n\t\t\tclass. These members can be accessed by name (with the\n\t\t\t
\n\t\t\tA name has the syntax\n\t\t\t
\n\t\t\tTScript imposes strict rules on the visibility of declarations\n\t\t\tbased on scopes.\n\t\t\tIn TScript, every block enclosed in curly braces is a scope.\n\t\t\tScopes can apparently be nested, as in the following example,\n\t\t\twhich contains five scopes: the global scope, a class, a\n\t\t\tfunction, and two blocks.\n\t\t\t
\n\t\t\t
\n\t\t\tNames of variables, functions, classes and namespaces declared\n\t\t\twithin a scope are only visible from within that scope, and from\n\t\t\twithin sub-scopes. They are neither visible before they are declared,\n\t\t\tnor after their enclosing scope ends. This makes it possible to have\n\t\t\tmultiple declarations of the same name, as along as they are found in\n\t\t\tdifferent scopes. The name always refers to the declaration in the\n\t\t\tinnermost scope:\n\t\t\t
\n\t\t\t
\n\t\t\tThis means that declarations of the same name mask each other, but\n\t\t\tthey do not result in errors.\n\t\t\t
\n\n\t\t\t\n\t\t\tAll names defined within a scope are visible within that scope, with the\n\t\t\texception of variables: they are visible only from the point of their\n\t\t\tdefinition onwards, but not before. This is implicit in the previous\n\t\t\texample, where the first print
-statement\n\t\t\toutputs 1, not 2. This is because the variable declared in the next line\n\t\t\tis not yet visible. That makes sense, because at the time the statement\n\t\t\tis executed, the variable does not exist yet. In contrast, the second\n\t\t\tto last print
-statement in the same scope\n\t\t\toutputs 2, which means that it refers to the variable within that scope.\n\t\t\t
\n\t\t\tFor other names (functions, classes, namespaces), the behavior is\n\t\t\tdifferent. All names within a scope are visible within the whole scope,\n\t\t\tirrespective of the order of declarations:\n\t\t\t
\n\t\t\t
\n\t\t\tBoth calls of f
output the value 2,\n\t\t\tindicating that the "inner" function is visible within the whole scope,\n\t\t\teven before it is defined. Hence, its definition masks the name\n\t\t\tf
within the whole scope.\n\t\t\t
\n\t\t\tDeclarations defined inside a namespace are accessed with the dot\n\t\t\toperator:\n\t\t\t
\n\t\t\t
\n\t\t\tThis works because the namespace N
is visible\n\t\t\tfrom the perspective of the statement. Its members\n\t\t\ta
and say
are not directly visible,\n\t\t\thowever, they can be accessed as members of N
.\n\t\t\t
\n\t\t\tWhen accessing members of a namespace many times it can be\n\t\t\tconvenient to make names from a namespace directly available in the\n\t\t\tcurrent scope:\n\t\t\t
\n\t\t\t
\n\t\t\tNames can even be imported into classes. Then variables and functions\n\t\t\tdefined in the namespace can be accessed like static members of the\n\t\t\tclass.\n\t\t\t
\n\n\t\t\t\n\t\t\tMembers of a class can be declared in any order. In This includes\n\t\t\tvariables, or in other words, attributes:\n\t\t\t
\n\t\t\t
\n\t\t\tInside a class it is possible to access the public and protected\n\t\t\tmembers of all super classes, although they are declared in unrelated\n\t\t\tscopes:\n\t\t\t
\n\t\t\t
\n\t\t\tWhen TScript encounters a name, then it proceeds as follows.\n\t\t\tIt checks all scopes for a declaration with the given name,\n\t\t\tstarting from the innermost scope and moving towards enclosing\n\t\t\tscopes until the global scope is processed. For each scope, it\n\t\t\tdoes the following:\n\t\t\t
\n\t\t\tThese rules imply that some names refer to objects that are not\n\t\t\taccessible, like in the following example:\n\t\t\t
\n\t\t\t
\n\t\t\tThe problem is that when g is called under the name h in the last\n\t\t\tline, then x has already gone out of scope. This can be avoided\n\t\t\tby turning g into a closure:\n\t\t\t
\n\t\t\t
\n\t\t\tDifferent operators have different precedence, i.e., binding\n\t\t\tstrength. In the following example, the order of operations\n\t\t\tdepends on the binding strength of the operators:\n\t\t\t
\n\t\t\t\n\t\t\tIn the second line the usual mathematical convention that multiplication\n\t\t\tis computed before addition is expected. This is realized in TScript by\n\t\t\tgiving operator *
a higher precedence\n\t\t\t(binding strength) than operator +
.\n\t\t\tThough, a higher precedence is traditionally expressed by a lower number,\n\t\t\tsee the table below.\n\t\t\t
\n\t\t\tSimilarly, the minus sign in the last statement is applied to the\n\t\t\tpower, not only to its base, since the exponentiation\n\t\t\toperator ^
binds stronger than the arithmetic negation\n\t\t\toperator -
.\n\t\t\t
\n\t\t\tAlso for operators of the equal precedence the evaluation order can matter\n\t\t\tfor the result, as in 7 - 4 - 3
. Furthermore,\n\t\t\texpressions can have side-effects, the order of which depends on the\n\t\t\tevaluation order. In TScript, the evaluation order is always well-defined.\n\t\t\tOperators of the same precedence and the expressions in between are\n\t\t\tevaluated either left-to-right or right-to-left.\n\t\t\t
\n\t\t\tThe precedence rules are summarized in the following table.\n\t\t\t
\n\t\t\tprecedence | operator type | operators | evaluation order |
---|---|---|---|
0 | right unary | [] . | left-to-right |
0 | right n-ary | () | left-to-right |
1 | binary | ^ | left-to-right |
2 | left unary | + - | right-to-left |
3 | binary | * / // % | left-to-right |
4 | binary | + - | left-to-right |
5 | binary | : | left-to-right |
6 | binary | == != < <= > >= | left-to-right |
7 | left unary | not | right-to-left |
8 | binary | and | left-to-right |
9 | binary | or xor | left-to-right |
10 | assignment | = += -= *= /= //= %= ^= | right-to-left |
\n\t\t\tEvery part of an expression can be enclosed in parentheses, which\n\t\t\tbind stronger than all operators. The most common reason is to\n\t\t\toverride operator precedence, as in the following example:\n\t\t\t
\n\t\t\tConstants are expressions that do not depend on the values\n\t\t\tof variables. Their main uses are as immediate values within\n\t\t\texpressions and as initializers of attributes. A further use\n\t\t\tis as default values of function parameters.\n\t\t\t
\n\t\t\t\n\t\t\tAll literals of\n\t\t\tnon-container types are constants. This includes all\n\t\t\tJSON types, but also\n\t\t\tfunctions (excluding non-static methods). Array and dictionary\n\t\t\tliterals are constants if all of their items are constants:\n\t\t\t
\n\t\t\tOther expressions are de-facto constants, in particular the\n\t\t\treturn values of functions without side-effects with constant\n\t\t\tparameters, e.g.,\n\t\t\t
\n\t\tStatements are instructions that change the state of the\n\t\tprogram. For example, they can modify a variable or change the\n\t\tprogram flow. Besides assignments and constructs like\n\t\tconditionals and loops, also simple expressions are considered\n\t\tstatements since they can have side effects, e.g., by calling\n\t\tprint
or wait
.\n\t\tStatements are formally defined as follows:\n\t\t
\n\t\t\tA block of statements has the following syntax:\n\t\t\t
\n\t\t\tAt the same time, the block acts as a scope, so the usual\n\t\t\tname lookup rules\n\t\t\tapply. This means that declarations made inside the block\n\t\t\tbecome invalid as soon as the block is left. Of course,\n\t\t\tfunctions declared inside the block can be returned or\n\t\t\tassigned to variables declared outside the block, and the\n\t\t\tsame holds for objects of locally declared classes.\n\t\t\t
\n\n\t\t\tAssignments have the following form:\n\t\t\t
\n\t\t\tAssignments are evaluated from right to left: the operator =
is\n\t\t\tthat the variable referenced by the
\n\t\t\tThe assignment operators += -= *= /= %= ^=
are\n\t\t\tcalled compound assignment operators. The statement\n\t\t\ta += 3;
is equivalent to\n\t\t\ta = a + 3;
, and the same applies to the other\n\t\t\tbinary arithmetic operators.\n\t\t\tHowever, this equivalence is not exact in general, since with compound\n\t\t\tassignment the lhs expression is evaluated only once. This difference\n\t\t\tis demonstrated in the following example:\n\t\t\t
\n\t\t\tAn expression followed by a semicolon is a valid statement.\n\t\t\tFor many expressions this is rather pointless:\n\t\t\t
\n\t\t\tA conditional control structure is denoted as follows:\n\t\t\t
\n\t\t\tA for-loop has the following syntax:\n\t\t\t
\n\t\t\tThe for-loop executes the
\n\t\t\tLooping over a range is the idiomatic way to execute code a number\n\t\t\tof times in a row. The loop counter provides an easy way to\n\t\t\tparameterize the repeated code:\n\t\t\t
\n\t\t\tLooping over an array works directly with a for-loop. For a\n\t\t\tdictionary it is not clear whether the loop variable shall hold\n\t\t\tkeys, values, or both. Therefore an explicit decision must be\n\t\t\tmade by the programmer, using the Dictionary methods\n\t\t\tkeys or\n\t\t\tvalues, as shown in\n\t\t\tthe following example:\n\t\t\t
\n\t\t\tIt is safe to modify the object iterated over during execution of the loop.\n\t\t\tThe loop is entirely unaffected by such modification because it iterates\n\t\t\tover a copy of the object. For example, the following is not an infinite loop:\n\t\t\t
\n\t\t\t\n\t\t\tEqually well, modifying the loop variable does not have an effect on the\n\t\t\tcontrol flow, because in the next iteration the variable is assigned the\n\t\t\tnext value from the container:\n\t\t\t
\n\t\t\tSometimes it is necessary to change the control flow during execution\n\t\t\tof the loop. We have seen that modifying the loop variable and the\n\t\t\tloop object does not achieve this effect. Instead, the following two\n\t\t\toperations work.\n\t\t\tThe loop a a whole can be aborted with break.\n\t\t\tThe current iteration can be aborted with continue.\n\t\t\tIt is not possible to extend a for loop during execution. If this is\n\t\t\ta requirement then a\n\t\t\twhile-do-loop\n\t\t\tcan be used.\n\t\t\t
\n\t\t',children:[]},{id:"while-do-loops",name:"While-Do-Loops",title:"While-Do-Loops",content:'\n\t\t\t\n\t\t\tThe while-do-loop syntax is as follows:\n\t\t\t
\n\t\t\tIt is easy to create an infinite while-do loop:\n\t\t\t
while true do { }
\n\t\t\tThe construction can actually be useful if the loop is aborted with a\n\t\t\t\n\t\t\tThe do-while-loop syntax is as follows:\n\t\t\t
\n\t\t\tIt is easy to create an infinite while loop:\n\t\t\t
do { } while true;
\n\t\t\tThe construction can actually be useful if the loop is aborted with a\n\t\t\t\n\t\t\tThe
\n\t\t\tThe return statement immediately returns from a function.\n\t\t\tIts syntax is as follows:\n\t\t\t
\n\t\t\tThe return statement first evaluates the expression, known as the\n\t\t\treturn value, then leaves the current function, and returns the\n\t\t\tvalue to the caller. In other words, the function call expression\n\t\t\tin the calling context evaluates to the return value.\n\t\t\t
\n\t\t\t\n\t\t\tWhen executed at global scope, the return statement terminates the\n\t\t\tprogram. A constructor as well as the global scope do not return a\n\t\t\tvalue. Therefore, in these contexts, a return statement must not\n\t\t\tcontain a return value.\n\t\t\t
\n\n\t\t\tAn exception is thrown with the following syntax:\n\t\t\t
\n\t\t\tExceptions are regularly used for error reporting across possibly\n\t\t\tdeeply nested function calls. The role of the exception is to\n\t\t\tprovide a useful description of the error, which can be either\n\t\t\thandled programmatically by the catch block, or reported to the\n\t\t\tuser.\n\t\t\t
\n\t\t\t\n\t\t\tSometimes only certain types of errors should be handled in a\n\t\t\tspecific
\n\t\t\tThe syntax of a
\n\t\t\tHowever, if an exception is thrown in the try-block or in any\n\t\t\tfunction called from this block, then execution continues in\n\t\t\tthe statement following
\n\t\tA type defines a set of values, which are of similar nature.\n\t\tThey are associated with operations acting on the value, i.e.,\n\t\tevaluating or manipulating values. The available data types\n\t\ttherefore define how information can be represented natively,\n\t\twhich units of information can be processed atomically, and\n\t\thow information can be aggregated.\n\t\t
\n\t\t\n\t\tTScript's core type system is rather minimal. It does not aim\n\t\tfor completeness, but it is extensible. For example, there is\n\t\tno built-in type representing a date, but it is easy enough to\n\t\tadd a class taking that role.\n\t\t
\n\t\t\n\t\tNot all types represent typical units of information, like bits,\n\t\tnumbers, and strings. Two such types are Function and Type. The\n\t\tability to use functions as types enables powerful programming\n\t\ttechniques. Types as values are used to check for the types of\n\t\tvariables referenced by variables at runtime.\n\t\t
\n\t\t\n\t\tProgrammers can extend the type system to new kinds of information\n\t\tby writing their own classes. Simple classes like a date class can\n\t\tbehave similar to atomic types. More complex classes can for\n\t\texample act as containers, or represent resources (like files).\n\t\tClasses support proper information hiding, which allows the\n\t\tprogrammer to separate implementation details from a public\n\t\tinterface.\n\t\t
\n\t\t\n\t\tTScript does not distinguish between built-in types and classes,\n\t\tin the sense that all types are equally capable of taking each role.\n\t\tFor example, it is perfectly legal to use a built-in type like\n\t\tInteger as a super class, which might make sense for a date class.\n\t\tHowever, it is not possible to overload operators. For classes, the\n\t\tcapabilities of operators must therefore be emulated with functions.\n\t\t
\n\t",children:[{id:"null",name:"Null",title:"The Type Null",content:'\n\t\t\t\n\t\t\tThe Null type has only a single value, the\n\t\t\tnull literal.\n\t\t\tThis value is immutable. It does not offer any operations.\n\t\t\tWhile it is clear that
constructor | \n\t\t\t\tThe constructor() creates a null\n\t\t\t\tvalue.\n\t\t\t |
---|
\n\t\t\tThe type Boolean represents the two logical values, denoted by the\n\t\t\tliterals\n\t\t\t
==
and !=
\n\t\t\t(and in fact, for Boolean, the operators\n\t\t\txor
and !=
\n\t\t\tare equivalent), but they cannot be ordered. Booleans are\n\t\t\tdemanded by the language as conditions in\n\t\t\tconditionals\n\t\t\tand pre- and\n\t\t\tpost-checked\n\t\t\tloops. Furthermore, they are frequently used as flags, and they\n\t\t\tcan be used to represent single bits.\n\t\t\t\n constructor | \n\t\t\t\tThe constructor(value) creates a copy\n\t\t\t\tof a boolean value.\n\t\t\t |
---|
\n\t\t\tThere exist 232 values of type Integer, namely\n\t\t\tthe whole numbers in the range -2147483648 = -231\n\t\t\tto 2147483647 = 231-1. Non-negative integers can be\n\t\t\trepresented directly as\n\t\t\tinteger literals.\n\t\t\tThe values are immutable.\n\t\t\t
\n\n\t\t\t\n\t\t\tIntegers can be combined with a number of unary and binary operators.\n\t\t\tWhen the result of such an operator is outside the integer range then\n\t\t\tthe result underflows or overflows, i.e., wraps around\n\t\t\tthe range, which can be understood as representatives of the integers\n\t\t\tmodulo 232. Being aware of this behavior is important\n\t\t\twhen dealing with large numbers, in particular since the operations are\n\t\t\tnot fully consistent from an algebraic perspective.\n\t\t\t
\n\t\t\tunary + | \n\t\t\t\tThe operator is a no-operation, or more correctly, the identity\n\t\t\t\tmapping. It returns its argument unmodified. It merely exists for\n\t\t\t\tsymmetry with unary -, e.g., in the following situation:\n\t\t\t\t |
---|---|
unary - | \n\t\t\t\tThe operator negates its argument. This operation overflows only\n\t\t\t\tfor the value -231 = -2147483648, resulting in\n\t\t\t\tthe exact same value.\n\t\t\t |
unary not | \n\t\t\t\tThe operator flips all 32 bits of its argument.\n\t\t\t |
binary + | \n\t\t\t\tAdd the arguments. The result is subject to under- and overflow.\n\t\t\t |
binary - | \n\t\t\t\tSubtract the arguments. The result is subject to under- and overflow.\n\t\t\t |
binary * | \n\t\t\t\tMultiply the arguments. The result is subject to under- and overflow,\n\t\t\t\twhich is particularly common for this operation. Example:\n\t\t\t\t |
binary / | \n\t\t\t\tDivide the arguments as reals. The arguments are first converted\n\t\t\t\tto reals, then they are divided as reals, and the result is of\n\t\t\t\ttype Real, even if the remainder of the integer division is zero.\n\t\t\t\t |
binary // | \n\t\t\t\tDivide the arguments as integers, defined as\n\t\t\t\t a // b = math.floor(a / b) \n\t\t\t\tNote that a * b = c implies\n\t\t\t\tc // a = b only if the multiplication\n\t\t\t\tdoes not overflow. Division is not well-defined in the modulo\n\t\t\t\tarithmetic implied by overflow!\n\t\t\t\tInstead "normal" integer division (without modulo) is assumed.\n\t\t\t\tThe result is rounded down to the closest integer. For example:\n\t\t\t\t |
binary % | \n\t\t\t\tRemainder of the integer division. The result is defined by\n\t\t\t\tthe following identity:\n\t\t\t\t a % b = a - (a // b) * b \n\t\t\t\tThis ensures that the result is always in the range\n\t\t\t\t 0 <= a % b < math.abs(b) \n\t\t\t\tFor example:\n\t\t\t\t |
binary ^ | \n\t\t\t\tThe operation n ^ m computes the m-th power of\n\t\t\t\tn. If m is non-negative then the result is an\n\t\t\t\tinteger, which is subject to the usual under- and overflow rules.\n\t\t\t\tFor negative exponent both arguments are converted to reals\n\t\t\t\tbefore applying the same operator for reals. Examples:\n\t\t\t\t |
binary and | \n\t\t\t\tThe operator returns the bitwise conjunction applied independently\n\t\t\t\tto all 32 bits of its arguments.\n\t\t\t\t\n\t\t\t |
binary or | \n\t\t\t\tThe operator returns the bitwise non-exclusive disjunction applied\n\t\t\t\tindependently to all 32 bits of its arguments.\n\t\t\t\t\n\t\t\t |
binary xor | \n\t\t\t\tThe operator returns the bitwise exclusive disjunction applied\n\t\t\t\tindependently to all 32 bits of its arguments.\n\t\t\t\t\n\t\t\t |
\n\t\t\tIntegers can be\n\t\t\tcompared for equality\n\t\t\tand they are ordered.\n\t\t\t
\n\t\t\t\n\t\t\tNote: bitwise operators have a very low precedence, i.e., a low binding\n\t\t\tstrength. Therefore, in a condition like x and 64 == 0
\n\t\t\tthe comparison operator ==
is executed\n\t\t\tbefore the bitwise operator and
. This\n\t\t\tis usually intended for logical operators, but not for bitwise operators.\n\t\t\tTherefore bitwise operators should always be used with parentheses:\n\t\t\t(x and 64) == 0
.\n\t\t\t
constructor | \n\t\t\t\tconstructor(value) converts the\n\t\t\t\tvalue to an integer. For integers this amounts to copying, reals\n\t\t\t\tare rounded down, and strings are parsed as decimal numbers.\n\t\t\t\tThe result is subject to integer overflow. Other types as well as\n\t\t\t\tthe special Real values infinity and not-a-number raise an error.\n\t\t\t |
---|
\n\t\t\tThe type Real represents floating point numbers according to the\n\t\t\tIEEE 754 standard.\n\t\t\tThis number format offers an excessive range and a precision of\n\t\t\tabout 15-16 decimal digits. Although the precision is more than\n\t\t\tsufficient for most tasks, one should be aware of its limitations\n\t\t\tlike rounding errors, which can result in catastrophic cancellation.\n\t\t\tThese aspects have been discussed in detail in\n\t\t\tthis classic article.\n\t\t\tPositive reals can be represented directly as\n\t\t\treal literals.\n\t\t\tThe values are immutable.\n\t\t\t
\n\n\t\t\t\n\t\t\tReals can be combined with a number of unary and binary operators.\n\t\t\tWhen the result of such an operator is outside the floating point range\n\t\t\tthen the result underflows (to zero) or overflows (to\n\t\t\tpositive or negative infinity). Being aware of this behavior is important\n\t\t\twhen dealing with large numbers, in particular since the operations are\n\t\t\tnot fully consistent from an algebraic perspective. Computations with\n\t\t\tinfinite values easily result in undefined results, which are encoded by\n\t\t\tthe special value NaN (not-a-number).\n\t\t\t
\n\t\t\tunary + | \n\t\t\t\tThe unary operator + is a no-operation,\n\t\t\t\tor more correctly, the identity mapping. It returns its argument\n\t\t\t\tunmodified. It merely exists for symmetry with unary -, i.e.,\n\t\t\t\tin the following situation:\n\t\t\t\t |
---|---|
unary - | \n\t\t\t\tThe unary operator - negates its argument.\n\t\t\t |
binary + | \n\t\t\t\tAdd the arguments. The result is subject to under- and overflow.\n\t\t\t |
binary - | \n\t\t\t\tSubtract the arguments. The result is subject to under- and overflow.\n\t\t\t |
binary * | \n\t\t\t\tMultiply the arguments. The result is subject to under- and overflow.\n\t\t\t |
binary / | \n\t\t\t\tDivide the arguments. The result is subject to under- and overflow.\n\t\t\t |
binary // | \n\t\t\t\tDivide the arguments and round the result down to the closest integer.\n\t\t\t\tYet, the result is of type Real. This operator is compatible with\n\t\t\t\tinteger division and with the modulo operation defined below.\n\t\t\t\tFor example:\n\t\t\t\t |
binary % | \n\t\t\t\tRemainder of the division, pretending that the quotient had been\n\t\t\t\trounded down to the nearest integer. The result is defined as\n\t\t\t\t a % b = a - b * (a // b) \n\t\t\t\t(for positive denominator, otherwise the result is negated).\n\t\t\t\tFor example:\n\t\t\t\t |
binary ^ | \n\t\t\t\tThe operation n ^ m computes the m-th power of\n\t\t\t\tn. Note that raising a negative number to a non-integer power is\n\t\t\t\tnot a well-defined operation, yielding the result NaN.\n\t\t\t |
\n\t\t\tReals can be\n\t\t\tcompared for equality\n\t\t\tand they are ordered.\n\t\t\tAll operations on reals can mix integers and reals. The integer is then\n\t\t\tconverted to a real, and the operation is executed with floating-point\n\t\t\tlogic, even if the numbers represented by the reals could be converted\n\t\t\tto integers without loss of precision.\n\t\t\t
\n\n\t\t\tconstructor | \n\t\t\t\tconstructor(value) converts the\n\t\t\t\tvalue to a real. For reals this amounts to copying, integers\n\t\t\t\tare converted, and strings are parsed as decimal numbers.\n\t\t\t\tThe result is subject to roundoff errors. All other types\n\t\t\t\tand all error conditions result in not-a-number.\n\t\t\t |
---|---|
isFinite | \n\t\t\t\tisFinite() test whether the value\n\t\t\t\tis finite. This is the case if it is neither infinite nor\n\t\t\t\tNaN.\n\t\t\t |
isInfinite | \n\t\t\t\tisInfinite() test whether the value\n\t\t\t\tis infinite. This is the case if it equals positive or\n\t\t\t\tnegative infinity.\n\t\t\t |
isNan | \n\t\t\t\tisNan() test whether the value\n\t\t\t\tis not-a-number.\n\t\t\t |
inf | \n\t\t\t\tstatic inf() returns positive\n\t\t\t\tinfinity.\n\t\t\t |
nan | \n\t\t\t\tstatic nan() returns not-a-number.\n\t\t\t |
\n\t\t\tThe type String represents text. A string is a sequence of\n\t\t\tcharacters of\n\t\t\tarbitrary length, also known as the size of the string.\n\t\t\tAlthough strings can contain any Unicode code point in the\n\t\t\trange U+0000 to U+FFFF,\n\t\t\tstring\n\t\t\tliterals allow to encode all characters with plain ASCII.\n\t\t\tDespite their sequence nature, strings are immutable. Hence\n\t\t\twhen the need for modifying a string arises then a new string\n\t\t\tmust be constructed.\n\t\t\t
\n\n\t\t\tbinary + | \n\t\t\t\tConcatenate two strings as sequences of characters. Only one of the\n\t\t\t\toperands needs to be a string in order to trigger the application of\n\t\t\t\tthis operator; the other operand is converted to a string as if it\n\t\t\t\thad been passed to the String constructor. The following two\n\t\t\t\tstatements are equivalent:\n\t\t\t\t |
---|---|
item access [] | \n\t\t\t\tIf the index is of type Integer then the single character at the\n\t\t\t\tspecified (zero-based) position is returned. The position must be\n\t\t\t\tvalid, i.e., it must neither be negative nor exceed the size of\n\t\t\t\tthe string. The character is returned as an integer in the range\n\t\t\t\t0 to 65535 representing the unicode code point.\n\t\t\t\t |
\n\t\t\tStrings can be\n\t\t\tcompared for equality\n\t\t\tand they are ordered.\n\t\t\tStrings are equal if they have the same length and all characters\n\t\t\tcoincide. They are ordered lexicographically.\n\t\t\t
\n\n\t\t\tconstructor | \n\t\t\t\tconstructor(value) converts the\n\t\t\t\tvalue to a string.\n\t\t\t |
---|---|
size | \n\t\t\t\tThe function size() returns the size of\n\t\t\t\tthe string, which is the number of characters in the sequence.\n\t\t\t |
find | \n\t\t\t\tThe function find(searchterm, start=0, backward=false) \n\t\t\t\tsearches for the string searchterm inside the string.\n\t\t\t\tIf backward is |
split | \n\t\t\t\tThe function split(separator) splits\n\t\t\t\tthe string into substrings, separated by the separator string.\n\t\t\t\tIt returns the substrings as an array. In case of two consecutive\n\t\t\t\tseparators or a separator at the beginning or end of the string\n\t\t\t\tthe resulting substring is empty. Example:\n\t\t\t\t |
toLowerCase | \n\t\t\t\tThe function toLowerCase() returns the string in only lower case characters.\n\t\t\t |
toUpperCase | \n\t\t\t\tThe function toUpperCase() returns the string in only upper case characters.\n\t\t\t |
replace | \n\t\t\t\tThe function replace(pattern, replacement) returns the string, but replaced all occurences of the string pattern with the string replacement.\n\t\t\t |
fromUnicode | \n\t\t\t\tThe static function fromUnicode(characters) \n\t\t\t\tconverts a single integer or an array of integers into a string\n\t\t\t\tthe character codes of which coincide with the integers.\n\t\t\t\t |
join | \n\t\t\t\tThe static function join(array, separator = "") \n\t\t\t\tcreates a string from an array of strings, separated by the (optional)\n\t\t\t\tseparator. To this end, the entries of the array and the separator\n\t\t\t\tare converted to strings at need. A typical example is to compose a\n\t\t\t\tsentence from words (with a single space as a separator):\n\t\t\t\t |
\n\t\t\tThe type Array is a container capable of holding multiple values,\n\t\t\tcalled items of the array. Items are arranged in a sequence. They\n\t\t\tare accessed by integer-valued indices. Arrays are mutable: items\n\t\t\tcan be inserted, deleted, and overwritten. Arrays can be created\n\t\t\tas literals.\n\t\t\tThese literals can contain arbitrary expressions (not necessarily\n\t\t\tliterals), which evaluate to the items.\n\t\t\t
\n\n\t\t\t\n\t\t\tAn array with n items has size n. The items are accessed with\n\t\t\tzero-based indices\n\t\t\tin the range 0 to n-1.\n\t\t\t
\n\n\t\t\titem access [] | \n\t\t\t\tIf the index is of type Integer then the single item at the\n\t\t\t\tspecified (zero-based) position is returned. The position must be\n\t\t\t\tvalid, i.e., it must neither be negative nor exceed the size of\n\t\t\t\tthe array.\n\t\t\t\tIf the index is of type Range then the sub-array described by the\n\t\t\t\trange is extracted. Parts of the range that lie outside the valid\n\t\t\t\tindex range are ignored.\n\t\t\t |
---|
\n\t\t\tArrays can be\n\t\t\tcompared for equality\n\t\t\tand they are ordered,\n\t\t\tif all of their items are ordered.\n\t\t\tArrays are equal if they have the same length and all items compare\n\t\t\tequal. They are ordered lexicographically. Ordering two array with\n\t\t\titems that are not ordered results in an error message.\n\t\t\t
\n\n\t\t\tconstructor | \n\t\t\t\tconstructor(size_or_other=0, value=null) \n\t\t\t\tcreates a new array. If size_or_other is an integer then the\n\t\t\t\tarray contains size_or_other copies of value.\n\t\t\t\tIf size_or_other is an array then the array is copied.\n\t\t\t\tif size_or_other is a range then an array is created\n\t\t\t\tthat contains the elements are the range as items.\n\t\t\t |
---|---|
size | \n\t\t\t\tThe function size() returns the size of\n\t\t\t\tthe array, which is the number of items.\n\t\t\t |
slice | \n\t\t\t\tThe function slice(start, end) returns the content of the given range in the array.\n\t\t\t |
push | \n\t\t\t\tThe function push(item) appends the\n\t\t\t\tgiven item to the array.\n\t\t\t |
pop | \n\t\t\t\tThe function pop() removes and returns\n\t\t\t\tthe last item from the array. When applied to the empty array it\n\t\t\t\traises an error.\n\t\t\t |
insert | \n\t\t\t\tThe function insert(position, item) \n\t\t\t\tinserts a new item at a given position. The index must be\n\t\t\t\tnon-negative and it must not exceed the array size.\n\t\t\t |
remove | \n\t\t\t\tThe function remove(range) removes\n\t\t\t\tthe indicated range of items from the array. If range is an\n\t\t\t\tinteger, then it is interpreted as range:range+1.\n\t\t\t |
sort | \n\t\t\t\tThe function sort(comparator=null) \n\t\t\t\tsorts the array in-place. Sorting is stable, i.e., the order of\n\t\t\t\tequivalent items is preserved. If comparator equals\n\t\t\t\t |
keys | \n\t\t\t\tThe function keys() returns the\n\t\t\t\trange 0:size() . Its main purpose is\n\t\t\t\tcompatibility with\n\t\t\t\tDictionary.keys.\n\t\t\t |
values | \n\t\t\t\tThe function values() returns the\n\t\t\t\tarray itself. Its main purpose is compatibility with\n\t\t\t\tDictionary.values.\n\t\t\t |
concat | \n\t\t\t\tstatic function concat(first, second) \n\t\t\t\tconcatenates two arrays. It returns the concatenated array.\n\t\t\t |
\n\t\t\tThe type Dictionary is a container capable of holding multiple\n\t\t\tvalues, called items of the dictionary. Items are accessed with\n\t\t\tstring-valued keys. Dictionaries are mutable: items can be inserted,\n\t\t\tdeleted, and overwritten. Dictionaries can be created as\n\t\t\tliterals.\n\t\t\tThese literals can contain arbitrary expressions (not necessarily\n\t\t\tliterals), which evaluate to the items.\n\t\t\t
\n\n\t\t\t\n\t\t\tA dictionary with n items has size n. The items are\n\t\t\taccessed with keys. Any two different strings form two different\n\t\t\tkeys, which can refer to different items. The empty string is a\n\t\t\tlegal key. Of course, not every possible string refers to an item,\n\t\t\tbut only keys that were explicitly defined.\n\t\t\t
\n\t\t\t\n\t\t\tConceptually, keys in a dictionary are not ordered. In particular,\n\t\t\tthe lexicographical order of strings does not apply. Instead, the\n\t\t\tkeys()
and values()
\n\t\t\tmethods report items chronologically, i.e., in the order they were\n\t\t\tinserted. This order also applies when converting a dictionary to\n\t\t\ta string.\n\t\t\t
item access [] | \n\t\t\t\tThe index is expected to be of type string. The string must be\n\t\t\t\ta valid key, i.e., an item with that key must have been defined\n\t\t\t\tbefore. The operator returns the value stored with the key.\n\t\t\t |
---|
\n\t\t\tDictionaries can be\n\t\t\tcompared for equality,\n\t\t\tbut they are not ordered.\n\t\t\tTwo dictionaries compare equal if they contain the same keys, and if\n\t\t\tthe items associated with these keys compare equal.\n\t\t\t
\n\n\t\t\tconstructor | \n\t\t\t\tconstructor(other=null) \n\t\t\t\tcreates a new dictionary. If other is null then the\n\t\t\t\tdictionary is empty. If other is a dictionary then it\n\t\t\t\tis copied.\n\t\t\t |
---|---|
size | \n\t\t\t\tThe function size() returns the size of\n\t\t\t\tthe dictionary, which is the number of items.\n\t\t\t |
has | \n\t\t\t\tThe function has(key) tests whether\n\t\t\t\tkey is the key of an item.\n\t\t\t |
remove | \n\t\t\t\tThe function remove(key) removes the\n\t\t\t\titem with the given key.\n\t\t\t |
keys | \n\t\t\t\tThe function keys() returns an array\n\t\t\t\tof strings holding all keys of the dictionary. This method\n\t\t\t\tprovides an easy way of iterating over all items of a dictionary:\n\t\t\t\t |
values | \n\t\t\t\tThe function values() returns an array\n\t\t\t\tholding all values of the dictionary. The order of the values\n\t\t\t\tis the same as the order of keys returned by\n\t\t\t\tfunction keys() .\n\t\t\t |
merge | \n\t\t\t\tstatic function merge(first, second) \n\t\t\t\tmerges two dictionaries, i.e., it joins the key/value pairs from\n\t\t\t\tboth dictionaries into a single dictionary. If a key appears in\n\t\t\t\tboth dictionaries then the value from the second one prevails.\n\t\t\t\tThe function returns the merged dictionary.\n\t\t\t |
\n\t\t\tThe Function type represents\n\t\t\tfunction declarations,\n\t\t\tmember function\n\t\t\tdeclarations applied to an object, and\n\t\t\tanonymous\n\t\t\tfunctions, possibly with enclosed parameters. This summarizes\n\t\t\tall blocks of code that can be\n\t\t\tcalled or invoked\n\t\t\tby providing parameters in parentheses.\n\t\t\tFunctions are immutable. The only operation they provide is the call\n\t\t\toperator.\n\t\t\t
\n\n\t\t\tfunction call () | \n\t\t\t\tCalls the function. See\n\t\t\t\tfunction calls\n\t\t\t\tfor details.\n\t\t\t |
---|
\n\t\t\tFunctions can be\n\t\t\tcompared for equality,\n\t\t\tbut they are not ordered.\n\t\t\t
\n\n\t\t\tconstructor | \n\t\t\t\tThe constructor(value) creates a copy\n\t\t\t\tof a function value.\n\t\t\t |
---|
\n\t\t\tThe Range type represents a range of integers. It is defined by\n\t\t\ttwo integers, begin and end. They define the half-open\n\t\t\trange\n\t\t\t
\n\t\t\t\n\t\t\tConsequently, in case\n\t\t\tof begin ≥ end the range is empty. Begin and end\n\t\t\tcan be any values in the valid integer\n\t\t\trange; in particular, they can be negative.\n\t\t\t
\n\t\t\t\n\t\t\tA range can be\n\t\t\tconstructed with the range constructor or with the\n\t\t\trange operator :.\n\t\t\tThe two options are equivalent:\n\t\t\t
\n\t\t\tRanges offer two rather trivial operations, both by means of the\n\t\t\titem access operator,\n\t\t\tnamely access to items by index, and slicing. The behavior is designed\n\t\t\tto mimic that of an array holding the elements of the range as items:\n\t\t\t
\n\t\t\tTwo ranges compare equal if and\n\t\t\tonly if begin and end coincide. This means that two empty ranges with\n\t\t\tdifferent begin and end do not compare equal, although they represent the\n\t\t\tsame (empty) set of integers. Ranges are not ordered.\n\t\t\t
\n\n\t\t\tconstructor | \n\t\t\t\tThe constructor(begin, end) creates a\n\t\t\t\tnew range from begin to end. Both arguments must be integers, or\n\t\t\t\treals representing integer values.\n\t\t\t |
---|---|
size | \n\t\t\t\tfunction size() returns the size of\n\t\t\t\tthe range. In order to avoid overflow for very large ranges the\n\t\t\t\treturn value is of type Real , although it is always\n\t\t\t\ta non-negative integer.\n\t\t\t |
begin | \n\t\t\t\tfunction begin() returns the begin of\n\t\t\t\tthe range.\n\t\t\t |
end | \n\t\t\t\tfunction end() returns the end of\n\t\t\t\tthe range.\n\t\t\t |
\n\t\t\tThe values of type Type represent types, i.e., built-in types and\n\t\t\tclasses. They are immutable. A type value can be constructed from\n\t\t\tany value.\n\t\t\t
\n\t\t\t\n\t\t\tType values are useful for three purposes:\n\t\t\t
\n\t\t\tType values do not offer any operations other than the function call\n\t\t\toperator, which invokes the constructor of the type, and the member\n\t\t\taccess operator, which accesses static members of the class.\n\t\t\tTwo type values compare equal if they refer to the same type. Types\n\t\t\tare not ordered.\n\t\t\t
\n\n\t\t\tconstructor | \n\t\t\t\tThe constructor(value) creates a new\n\t\t\t\ttype object. It describes the type of value.\n\t\t\t |
---|---|
superclass | \n\t\t\t\tstatic function superclass(type) \n\t\t\t\treturns a type object representing the direct super class of\n\t\t\t\tthe given type, or null if the it does not have a super\n\t\t\t\tclass.\n\t\t\t |
isOfType | \n\t\t\t\tstatic function isOfType(value, type) \n\t\t\t\ttests whether value is of type type or a derived\n\t\t\t\tclass. This test is equivalent to\n\t\t\t\tType.isDerivedFrom(Type(value), type) .\n\t\t\t |
isDerivedFrom | \n\t\t\t\tstatic function isDerivedFrom(subclass, superclass) \n\t\t\t\ttests whether subclass inherits superclass as a direct\n\t\t\t\tor indirect base (including the case that the types coincide).\n\t\t\t |
\n\t\t\tA Class is a user-defined type. It is created through a\n\t\t\tclass declaration;\n\t\t\tthe technical aspects of class declarations are discussed right\n\t\t\tthere.\n\t\t\t
\n\t\t\t\n\t\t\tClasses allow the programmer to extend the\n\t\t\tsystem of built-in types. They open\n\t\t\tup the whole world of\n\t\t\tobject-oriented programming,\n\t\t\ta programming paradigm in which data and functionality is organized\n\t\t\tinto objects, which are instances of classes. Objects organize data\n\t\t\tinto semantically meaningful units. Classes bind functions operating\n\t\t\ton these chunks to the corresponding object. Classes define a public\n\t\t\t(possibly a protected) interface, defining the functionality. The\n\t\t\timplementation of the functionality is opaque to the user of a class\n\t\t\tor object, and hence allows the implementer to modify implementation\n\t\t\tdetails without affecting the outside world. This principle is known\n\t\t\tas "encapsulation" or "information hiding". Furthermore, classes can\n\t\t\textend existing types through (single) inheritance.\n\t\t\t
\n\n\t\t\t\n\t\t\tThe following is a non-trivial example of a (rather minimal) class\n\t\t\trepresenting a date.\n\t\t\t
\n\t\t\t\n\tThis is the reference implementation of the TScript programming language.\n\tThe software/website is provided under an\n\tMIT license.\n\t
\n\n\t\n\tCopyright (C) by Tobias Glasmachers.\n\t
\n\t\n\tPermission is hereby granted, free of charge, to any person obtaining a copy\n\tof this software and associated documentation files (the "Software"), to deal\n\tin the Software without restriction, including without limitation the rights\n\tto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n\tcopies of the Software, and to permit persons to whom the Software is\n\tfurnished to do so, subject to the following conditions:\n\t
\n\t\n\tThe above copyright notice and this permission notice shall be included in\n\tall copies or substantial portions of the Software.\n\t
\n\t\n\tTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n\tIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n\tFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n\tAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n\tLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n\tOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n\tTHE SOFTWARE.\n\t
\n\n\t\n\tThe TScript IDE uses the following library:\n\t
\n\tThis is the reference documentation of the TScript standard library.\n\tIts core consists of a hand full of general utility functions and a set\n\tof standard mathematical functions. Further parts of the library cover\n\tturtle and canvas graphics, as well as sound output.\n\t
\n",children:[{id:"core",name:"Core Functions",title:"Core Functions",content:'\n\t\t\n\t\tThe functions described in this section perform essential core tasks.\n\t\tInstead of being library functions, they could equally well be\n\t\timplemented as language features.\n\t\t
\n\t\tterminate | \n\t\t\tThe function terminate() immediately\n\t\t\tterminates the program. This is considered "normal"\n\t\t\ttermination, in contrast to termination due to an error.\n\t\t |
---|---|
assert | \n\t\t\tThe function assert(condition, message) \n\t\t\ttests whether condition evaluates to false. In that case it\n\t\t\tstops the program and emits message as an error message.\n\t\t\tThis function should be used to verify that invariants of the\n\t\t\tprogram are fulfilled. Ideally, an assertion should never fail,\n\t\t\tand if it does then it indicates a bug. Assertions should not be\n\t\t\tused to check user input or other error conditions. An exception\n\t\t\tshould be thrown in that case.\n\t\t |
error | \n\t\t\tThe function error(message) \n\t\t\tstops the program and emits message as an error message.\n\t\t\tThis function should be used to report unrecoverable errors. As\n\t\t\tsuch, errors have a different role than exceptions, which should\n\t\t\tindicate recoverable errors.\n\t\t |
same | \n\t\t\tThe function same(first, second) tests\n\t\t\twhether its arguments refer to the same object.\n\t\t\t\n\t\t\t \n\t\tExample\n\t\t\t |
version | \n\t\t\tThe function version() returns a\n\t\t\tdictionary describing the current TScript version. The\n\t\t\treturned dictionary holds the following fields:\n\t\t\t
|
\n\t\t\tThe function print(text) outputs its\n\t\t\targument as a new line into the message area. For this purpose,\n\t\t\tthe argument is converted to a string.\n\t\t | |
alert | \n\t\t\tThe function alert(text) opens a modal\n\t\t\tmessage box presenting the text to the user. For this purpose,\n\t\t\tthe argument is converted to a string. The program continues\n\t\t\tafter the user has closed the message box.\n\t\t |
confirm | \n\t\t\tThe function confirm(text) opens a\n\t\t\tmodal message box presenting the text to the user. For this\n\t\t\tpurpose, the argument is converted to a string. The user can\n\t\t\teither confirm or cancel the dialog, resulting in a return\n\t\t\tvalue of true or\n\t\t\tfalse , respectively. The program\n\t\t\tcontinues after the user has processed the message box.\n\t\t\t\n\t\t\t \n\t\tExample\n\t\t\t |
prompt | \n\t\t\tThe function prompt(text) opens a\n\t\t\tmodal message box presenting the text to the user. For this\n\t\t\tpurpose, the argument is converted to a string. The user can\n\t\t\tinput a string in response, which is returned by the function.\n\t\t\tThe program continues after the user has processed the message\n\t\t\tbox.\n\t\t\t\n\t\t\t \n\t\tExample\n\t\t\t |
wait | \n\t\t\tThe function wait(ms) delays program\n\t\t\texecution for ms milliseconds.\n\t\t |
time | \n\t\t\tThe function time() returns the number\n\t\t\tof milliseconds since midnight 01.01.1970\n\t\t\tUTC\n\t\t\tas a real.\n\t\t |
localtime | \n\t\t\tThe function localtime() returns the number\n\t\t\tof milliseconds since midnight 01.01.1970\n\t\t\tas a real. The value refers to local time, i.e., taking the\n\t\t\tlocal time zone and daylight saving time into account.\n\t\t |
exists | \n\t\t\tThe function exists(key) returns\n\t\t\t |
load | \n\t\t\tThe function load(key) returns the\n\t\t\tvalue that was stored with the given key. If the key does\n\t\t\tnot exist then the function reports an error. This is\n\t\t\tanalogous to loading data from a file into memory.\n\t\t |
save | \n\t\t\tThe function save(key, value) stores\n\t\t\tthe value with the given key to a persistent storage. The\n\t\t\tstored value remains stored even after the program terminates.\n\t\t\tIt can be loaded at any later time, even by a different program.\n\t\t\tThis is analogous to storing data in a file. The stored data is\n\t\t\trestricted to JSON format. This means that the value must be of\n\t\t\ttype Null, Boolean, Integer, Real, or String, or it must be an\n\t\t\tArray or Dictionary holding JSON values. JSON values must not\n\t\t\tform cycles: an Array or Dictionary value may not be nested,\n\t\t\ti.e., be contained as an item inside itself or one of its\n\t\t\tsub-items.\n\t\t |
listKeys | \n\t\t\tThe function listKeys() returns an array containing the keys to all stored values.\n\t\t |
deepcopy | \n\t\t\t \n\t\t\tThe
\n\t\t\t \n\t\tExample\n\t\t\t |
setEventHandler | \n\t\t\tThe function setEventHandler(event, handler) \n\t\t\tsets an event handler for a named event. The handler is a callback\n\t\t\tfunction that is called with an event parameter whenever the\n\t\t\tcorresponding event is triggered. The event name is provided\n\t\t\tas a string. The most common use of this function is to handle\n\t\t\tGUI-related events emitted by the canvas.\n\t\t\tThe standard library provides a "timer" event,\n\t\t\twhich is fired roughly every 20 milliseonds.\n\t\t\tenterEventMode . The event handler is\n\t\t\tcalled with an event parameter, the type of which depends on the\n\t\t\tevent type. For the timer event, the event is simply a\n\t\t\tsetEventHandler with\n\t\t\thandler = null removes the handler for\n\t\t\tthe given event type.\n\n\t\t\tWhen events take more than 20 milliseconds to complete,\n\t\t\tthe "timer" event only gets called once for this timespan.\n\t\t |
enterEventMode | \n\t\t\tThe function enterEventMode() puts the\n\t\t\tprogram into event handling mode. The function returns only after\n\t\t\tcalling quitEventMode from within an\n\t\t\tevent handler. The program still continues to run, handling all\n\t\t\tevents received from external sources, like mouse and keyboard\n\t\t\tevents for the canvas. Of course, at least one event handler\n\t\t\tshould be registered before calling this function.\n\t\t |
quitEventMode | \n\t\t\tThe function quitEventMode(result = null) \n\t\t\tputs the program back into normal processing mode. It is usually\n\t\t\tcalled from within an event handler. The program handles all\n\t\t\tqueued events, then it continues with the next statement\n\t\t\tfollowing enterEventMode . The parameter\n\t\t\tresult becomes the return value of\n\t\t\tfunction enterEventMode() .\n\t\t |
\n\t\tThe namespace math
contains a number\n\t\tof functions computing powers, logarithms, trigonometric and\n\t\thyperbolic functions. Unless stated differently, all functions\n\t\toperate on real numbers, and integers are converted to reals.\n\t\tAll trigonometric functions work with radians.\n\t\t
pi | \n\t\t\tThe function math.pi() returns the constant\n\t\t\tpi.\n\t\t |
---|---|
e | \n\t\t\tThe function math.e() returns Euler\'s constant\n\t\t\te.\n\t\t |
abs | \n\t\t\tThe function math.abs(x) returns the absolute\n\t\t\tvalue of its argument. For an integer argument the result is of type\n\t\t\tinteger. The function overflows only for the value -2147483648.\n\t\t |
sqrt | \n\t\t\tThe function math.sqrt(x) returns the square\n\t\t\troot of its argument.\n\t\t |
cbrt | \n\t\t\tThe function math.cbrt(x) returns the cubic\n\t\t\troot of its argument.\n\t\t |
floor | \n\t\t\tThe function math.floor(x) returns the argument\n\t\t\trounded down, i.e., the closest integer not larger than x. Although\n\t\t\tthe return value is an integer, it is of type Real \n\t\t\tto avoid integer overflow.\n\t\t |
round | \n\t\t\tThe function math.round(x) returns the argument\n\t\t\trounded to the nearest integer. Although the return value is an integer,\n\t\t\tit is of type Real to avoid integer overflow.\n\t\t |
ceil | \n\t\t\tThe function math.ceil(x) returns the argument\n\t\t\trounded up, i.e., the closest integer not smaller than x. Although\n\t\t\tthe return value is an integer, it is of type Real \n\t\t\tto avoid integer overflow.\n\t\t |
sin | \n\t\t\tThe function math.sin(x) returns the\n\t\t\tsine\n\t\t\tof its argument in radians.\n\t\t |
cos | \n\t\t\tThe function math.cos(x) returns the\n\t\t\tcosine\n\t\t\tof its argument in radians.\n\t\t |
tan | \n\t\t\tThe function math.tan(x) returns the\n\t\t\ttangent\n\t\t\tof its argument in radians.\n\t\t |
sinh | \n\t\t\tThe function math.sinh(x) returns the\n\t\t\thyperbolic sine\n\t\t\tof its argument.\n\t\t |
cosh | \n\t\t\tThe function math.cosh(x) returns the\n\t\t\thyperbolic cosine\n\t\t\tof its argument.\n\t\t |
tanh | \n\t\t\tThe function math.tanh(x) returns the\n\t\t\thyperbolic tangent\n\t\t\tof its argument.\n\t\t |
asin | \n\t\t\tThe function math.asin(x) returns the inverse\n\t\t\tsine\n\t\t\tof its argument. The return value is an angle in radians.\n\t\t |
acos | \n\t\t\tThe function math.acos(x) returns the inverse\n\t\t\tcosine\n\t\t\tof its argument. The return value is an angle in radians.\n\t\t |
atan | \n\t\t\tThe function math.atan(x) returns the inverse\n\t\t\ttangent\n\t\t\tof its argument. The return value is an angle in radians.\n\t\t |
atan2 | \n\t\t\tThe function math.atan2(y, x) returns the inverse\n\t\t\ttangent\n\t\t\tof y/x. This is the angle between the vectors (x, y) and (1, 0) in radians.\n\t\t |
asinh | \n\t\t\tThe function math.asinh(x) returns the inverse\n\t\t\thyperbolic sine\n\t\t\tof its argument.\n\t\t |
acosh | \n\t\t\tThe function math.acosh(x) returns the inverse\n\t\t\thyperbolic cosine\n\t\t\tof its argument.\n\t\t |
atanh | \n\t\t\tThe function math.atanh(x) returns the inverse\n\t\t\thyperbolic tangent\n\t\t\tof its argument.\n\t\t |
exp | \n\t\t\tThe function math.exp(x) returns the\n\t\t\texponential function\n\t\t\tof its argument.\n\t\t |
log | \n\t\t\tThe function math.log(x) returns the\n\t\t\tnatural logarithm\n\t\t\tof its argument.\n\t\t |
log2 | \n\t\t\tThe function math.log2(x) returns the\n\t\t\tlogarithm with base 2\n\t\t\tof its argument.\n\t\t |
log10 | \n\t\t\tThe function math.log10(x) returns the\n\t\t\tlogarithm with base 10\n\t\t\tof its argument.\n\t\t |
pow | \n\t\t\tThe function math.pow(b, e) returns the e-th power of b.\n\t\t\tIt is an alternative to operator ^\n\t\t\tthat always works with data type Real .\n\t\t |
sign | \n\t\t\tThe function math.sign(x) returns the\n\t\t\tsign of its argument, encoded as -1, 0, or +1.\n\t\t\tThe return type is an integer if the argument is, otherwise it is real.\n\t\t |
min | \n\t\t\tThe function math.min(a, b) returns the smaller\n\t\t\tof its two arguments. The function is applicable to non-numeric arguments\n\t\t\tas long as they are ordered. It is equivalent to\n\t\t\t if a <= b then return a; else return b; \n\t\t |
max | \n\t\t\tThe function math.max(a, b) returns the larger\n\t\t\tof its two arguments. The function is applicable to non-numeric arguments\n\t\t\tas long as they are ordered. It is equivalent to\n\t\t\t if a >= b then return a; else return b; \n\t\t |
random | \n\t\t\tThe function math.random() returns a real number\n\t\t\tdrawn from the uniform distribution on the half-open unit interval [0, 1[.\n\t\t |
\n\t\tThe functions in this section control the "turtle", an imaginary robot\n\t\tequipped with a pen that can move around and draw lines. The turtle\n\t\tmoves in a two-dimensional area. It is described by a Cartesian\n\t\tcoordinate system with horizontal (x) and vertical (y) axes. The origin\n\t\tis at the center of the area, and the visible area extends from -100 to\n\t\t+100 in each direction. The turtle can leave the visible area.\n\t\t
\n\t\t\n\t\tAt program start, the turtle is located at the origin of its coordinate\n\t\tsystem, it is equipped with a black pen, and it faces upwards, or in\n\t\tother words, along the positive y-axis. The turtle can move and turn.\n\t\tWhile doing so it can lower and raise a pen. While lowered, the pen\n\t\tdraws the path taken by the turtle. The result of such drawing is known\n\t\tas "turtle graphics". The color of the pen can be changed.\n\t\t
\n\t\treset | \n\t\t\tThe function reset(x=0, y=0, degrees=0, down=true) \n\t\t\tplaces the turtle at position (x, y) on its drawing area.\n\t\t\tIts orientation is given by degrees, the color is set to\n\t\t\tblack, and the pen is active if down is true. Using this\n\t\t\tfunction for actual drawing is considered improper use, or "cheating",\n\t\t\tsince this operation is not available to an actual robot. The\n\t\t\tintended use is to initialize the turtle in a different position\n\t\t\tthan the center.\n\t\t |
---|---|
move | \n\t\t\tThe function move(distance) moves the\n\t\t\tturtle forward by the given distance, or backward if the distance\n\t\t\tis negative. If the pen is down in this state then a line is drawn.\n\t\t |
turn | \n\t\t\tThe function turn(degrees) rotates the\n\t\t\tturtle clockwise, where 360 degrees are one full rotation.\n\t\t\tA negative angle corresponds to a counter-clockwise rotation.\n\t\t |
color | \n\t\t\tThe function color(red, green, blue) \n\t\t\tsets the color of the pen, defined by red, green and blue components.\n\t\t\tAll values are clipped to the range [0, 1].\n\t\t |
pen | \n\t\t\tThe function pen(down) lifts the pen if\n\t\t\tdown is false and lowers the pen if down is true.\n\t\t |
\n\t\tThe functions in this section control the "canvas", a rectangular\n\t\tsurface for drawing geometric shapes and text. Canvas graphics is\n\t\tsignificantly more flexible than turtle graphics. The canvas\n\t\tprovides user-triggered mouse and keyboard events.\n\t\t
\n\t\t\n\t\tThe canvas is a two-dimensional grid of pixels. Each pixel covers\n\t\tan area of size 1x1. The origin of the coordinate system is the\n\t\ttop/left corner of the top/left pixel. The x-coordinate grows\n\t\ttowards the right, while the y-coordinate grows towards the bottom.\n\t\tThe latter is in contrast to a standard mathematical coordinate\n\t\tsystem, however, the convention is common for computer screens.\n\t\tThe size of the canvas depends on the size of the window containing\n\t\tthe canvas. Drawing outside the canvas has no effect.\n\t\t
\n\t\t\n\t\tNote that the above convention means that integer coordinates refer\n\t\tto the corners of pixels. Hence, the coordinates of the center of\n\t\tthe top/left pixel are (0.5, 0.5). All drawing operations are\n\t\tdefined in continuous coordinates. Conceptually, drawing a red line\n\t\tof width 1 from point (10, 10) to point (20, 10) spills red ink\n\t\tover the rectangle with corners (10, 9.5), (10, 10.5), (20, 10.5),\n\t\t(20, 9.5). Therefore the pixels in rows y=9 and y=10 are covered\n\t\tby 50% red ink. When drawing on top of white background, then the\n\t\tdrawing command results in two consecutive horizontal pixel rows\n\t\tof light red color. However, the intended is most probably to fill\n\t\ta single pixel row with fully red color. This is achieved by\n\t\tdrawing a line of width 1 from (10, 10.5) to (20, 10.5). This shift\n\t\tof 0.5 is a bit unintuitive at first, and it is caused by integer\n\t\tcoordinates referring to the corners of pixels, not to their centers.\n\t\t
\n\t\t\n\t\tCanvas drawing is stateful. This means that properties of drawing\n\t\toperations like line and fill color and line width are set before\n\t\tthe actual drawing commands are issued. This makes it easy to draw,\n\t\te.g., many lines of the same width and color in sequence.\n\t\t
\n\t\t\n\t\tAll drawing functions can also be used for offline drawing onto a\n\t\tBitmap
object. The target object of all drawing\n\t\toperations can be set with setDrawingTarget
. The\n\t\tdrawing state is separate per target. This means that changing a\n\t\tproperty (like the line color) for one target does not affect the\n\t\tsame property for any other target.\n\t\t
\n\t\tThe canvas namespace provides a large number of functions. They are\n\t\tsplit into the following categories: reading properties, setting\n\t\tproperties, raw pixel access, transformations, drawing, and managing\n\t\tevents.\n\t\t
\n\n\t\twidth | \n\t\t\tThe function width() returns the current\n\t\t\twidth of the canvas in pixels.\n\t\t |
---|---|
height | \n\t\t\tThe function height() returns the current\n\t\t\theight of the canvas in pixels.\n\t\t |
setLineWidth | \n\t\t\tThe function setLineWidth(width) sets\n\t\t\tthe line width. The parameter width \n\t\t\tmust be a positive number.\n\t\t |
---|---|
setLineColor | \n\t\t\tThe function setLineColor(red, green, blue, alpha) \n\t\t\tsets the line color. All arguments are in the range 0 to 1. The\n\t\t\talpha (opacity) argument is optional, it defaults to 1.\n\t\t |
setFillColor | \n\t\t\tThe function setFillColor(red, green, blue, alpha) \n\t\t\tsets the fill color. All arguments are in the range 0 to 1. The\n\t\t\talpha (opacity) argument is optional, it defaults to 1.\n\t\t |
setOpacity | \n\t\t\tThe function setOpacity(alpha) \n\t\t\tsets a global opacity (alpha) value for all drawing operations.\n\t\t\tA value of 0 means that operations are fully transparent and hence\n\t\t\thave no effect, while a value of 1 means that drawing is fully\n\t\t\topaque.\n\t\t |
setFont | \n\t\t\tThe function setFont(fontface, fontsize) \n\t\t\tsets the current font. The fontface is a string, it must correspond\n\t\t\tto a font existing on the system. The fontsize is defined in pixels,\n\t\t\tit must be a positive number. The default font is a 16px Helvetica\n\t\t\tfont.\n\t\t |
setTextAlign | \n\t\t\tThe function setTextAlign(alignment) \n\t\t\tsets the text alignment. Possible values are\n\t\t\t"left" (the default),\n\t\t\t"center" , and\n\t\t\t"right" .\n\t\t\tThe position given in text drawing commands is relative to the\n\t\t\talignment.\n\t\t |
\n\t\tNote that the pixel coordinates for raw pixel access are not\n\t\taffected by the current transformation.\n\t\t
\n\t\tgetPixel | \n\t\t\tThe function getPixel(x, y) returns the\n\t\t\t"raw" pixel value as an array of four numbers, encoding the RGBA\n\t\t\tcolor value. Each component (red, green, blue, and alpha) is an\n\t\t\tinteger in the range 0 to 255. This is the format in which the\n\t\t\tcolor information is stored in the graphics hardware.\n\t\t |
---|---|
setPixel | \n\t\t\tThe function setPixel(x, y, data) sets\n\t\t\ta raw pixel value. The data argument is an array of four integers\n\t\t\twith the same meaning as the return value of getPixel .\n\t\t |
clear | \n\t\t\tThe function clear() erases all drawn\n\t\t\tcontent by filling the entire canvas with the current fill color.\n\t\t\tIt also resets the transformation (see function reset() below).\n\t\t |
---|---|
line | \n\t\t\tThe function line(x1, y1, x2, y2) draws\n\t\t\ta line from (x1, y1) to (x2, y2) using the current line width and\n\t\t\tline color.\n\t\t |
rect | \n\t\t\tThe function rect(left, top, width, height) \n\t\t\tdraws the outline of a rectangle with the current line width and\n\t\t\tline color.\n\t\t |
fillRect | \n\t\t\tThe function fillRect(left, top, width, height) \n\t\t\tfills a rectangle with the current fill color.\n\t\t |
frameRect | \n\t\t\tThe function frameRect(left, top, width, height) \n\t\t\tfills a rectangle with the current fill color and draws the outline with\n\t\t\tthe current line color and line width.\n\t\t |
circle | \n\t\t\tThe function circle(x, y, radius) \n\t\t\tdraws the outline of a circle with the current line width and\n\t\t\tline color.\n\t\t |
fillCircle | \n\t\t\tThe function fillCircle(x, y, radius) \n\t\t\tfills a circle with the current fill color.\n\t\t |
frameCircle | \n\t\t\tThe function frameCircle(x, y, radius) \n\t\t\tfills a circle with the current fill color and draws the outline with\n\t\t\tthe current line color and line width.\n\t\t |
curve | \n\t\t\tThe function curve(points, closed) draws\n\t\t\ta polygon given by the array points , each\n\t\t\tentry of which is an array containing (x, y) coordinates. For example,\n\t\t\tthe array [[100, 100], [200, 100], [100, 200]] \n\t\t\tspecifies a curve consisting of two lines (three lines forming a triangle\n\t\t\tif the curve is closed), connecting the points (100, 100), (200, 100),\n\t\t\tand (100, 200). If the optional argument closed \n\t\t\tis set to true then the first and the last point\n\t\t\tare connected, resulting in a closed polygon. The curve is drawn with the\n\t\t\tcurrent line width and line color.\n\t\t |
fillArea | \n\t\t\tThe function fillArea(points) fills the\n\t\t\tclosed polygon given by points (see function\n\t\t\tcurve) with the current fill color.\n\t\t |
frameArea | \n\t\t\tThe function frameArea(points) fills the\n\t\t\tclosed polygon given by points (see function\n\t\t\tcurve) with the current fill color, and then draws the polygon outline\n\t\t\twith the given line color and line width.\n\t\t |
text | \n\t\t\tThe function text(x, y, str) draws the string\n\t\t\tstr at position (x, y), relative to the\n\t\t\tcurrent text alignment, using the current font and fill color.\n\t\t |
paintImage | \n\t\t\tThe function paintImage(x, y, source) draws an\n\t\t\timage source at position (x, y). The source can\n\t\t\tbe a canvas.Bitmap object or null . In the latter case, the\n\t\t\tcurrent canvas is drawn.\n\t\t |
paintImageSection | \n\t\t\tThe function paintImage(dx, dy, dw, dh, source, sx, sy, sw, sh) \n\t\t\tdraws a section of the image source \n\t\t\tspecified by the rectangle (sx, sy, sw, sh) into the rectangle\n\t\t\tspecified by (dx, dy, dw, dh) on the target canvas. The source can\n\t\t\tbe a canvas.Bitmap object or null . In the latter case,\n\t\t\ta section from the current canvas is drawn.\n\t\t |
reset | \n\t\t\tThe function reset() resets the current\n\t\t\ttransformation. Afterwards the origin of the coordinate system is\n\t\t\tthe top left corner, with axes extending to the right and to the\n\t\t\tbottom.\n\t\t\t |
---|---|
shift | \n\t\t\tThe function shift(dx, dy) translates\n\t\t\tthe origin of the coordinate system by the vector (dx, dy).\n\t\t\t |
scale | \n\t\t\tThe function scale(factor) scales the\n\t\t\tcoordinate system by the given factor.\n\t\t\t |
rotate | \n\t\t\tThe function rotate(angle) rotates the\n\t\t\tcoordinate system clockwise by the given angle. The angle is given\n\t\t\tin radians, i.e., a full rotation corresponds to the angle\n\t\t\t2 * math.pi() .\n\t\t\t |
transform | \n\t\t\tThe function transform(A, b) transforms\n\t\t\tcoordinates (x, y) into new coordinates A (x, y) + b, where A is\n\t\t\tthe 2x2 matrix [[A11, A12], [A21, A22]] \n\t\t\tand b is the vector [b1, b2] .\n\t\t\t |
\n\t\tThe canvas emits the following events:\n\t\t\t
event name | event type | meaning |
---|---|---|
"canvas.mousemove" | MouseMoveEvent | mouse pointer moved to new position within the canvas |
"canvas.mouseout" | Null | mouse pointer left the canvas |
"canvas.mousedown" | MouseButtonEvent | mouse button pressed |
"canvas.mouseup" | MouseButtonEvent | mouse button released |
"canvas.keydown" | KeyboardEvent | keyboard key pressed |
"canvas.keyup" | KeyboardEvent | keyboard key released |
"canvas.resize" | ResizeEvent | canvas resized |
setEventHandler
.\n\t\t\n\t\t\n\t\tThe different event types are lightweight classes providing\n\t\tpublic attributes. They are defined as follows:\n\t\t
\n\t\t
\n\t\tButtons are named "left"
,\n\t\t"middle"
, and "right"
.\n\t\tKeys are named according to the\n\t\tJavaScript rules.\n\t\t
\n\t\tMouse pointer coordinates always refer to untransformed canvas pixels:\n\t\tif a transformation has been performed before the event occurs (like\n\t\tshift(100, 100);
) then drawing actions inside the\n\t\tevent handler are affected by the transformation. However, the coordinates\n\t\treported in the event object are unaffected; they always refer to the\n\t\toriginal canvas coordinates.\n\t\t
\n\t\tThe class Bitmap
fulfills two purposes: it allows for\n\t\toffline drawing, and it offers a convenient way to use image resources\n\t\tin programs.\n\t\t
Bitmap | \n\t\t\tBitmap(resourceOrWidth, height = null) \n\t\t\tconstructs a bitmap (image) object. The parameter\n\t\t\tresourceOrWidth is either a resource string\n\t\t\tcontaining a data URI, or an integer\n\t\t\tspecifying the width. The height parameter is relevant only in the\n\t\t\tlatter case. The constructor creates a bitmap image with the given\n\t\t\tcontent, or of the given dimensions. A bitmap created from dimensions\n\t\t\tis initially transparent black.\n\t\t |
---|
Bitmap.width() | \n\t\t\tThe method returns the width of the bitmap in pixels. An alternative\n\t\t\tway of querying the width of a bitmap is to set it as the current\n\t\t\tdrawing target, then call canvas.width() , and finally\n\t\t\treset the old drawing target. This method avoids the complication of\n\t\t\tthat procedure.\n\t\t |
---|---|
Bitmap.height() | \n\t\t\tThe method returns the width of the bitmap in pixels. An alternative\n\t\t\tway of querying the width of a bitmap is to set it as the current\n\t\t\tdrawing target, then call canvas.height() , and finally\n\t\t\treset the old drawing target. This method avoids the complication of\n\t\t\tthat procedure.\n\t\t |
TScript supports playback of audio. The class Sound
\n\t\t\trepresent sound samples. A sound sample consists of channels, where each channel\n\t\t\tis represented by a buffer: an array of numbers, with values ranging from -1 to 1.\n\t\t\tAs an alternative to providing explicit buffers, sound objects can be constructed\n\t\t\tfrom media resources encoded as a data URI in a string.\n\t\t\t
\n\t\t\tEach sound sample can be played an arbitrary number of times, and even\n\t\t\trepeatedly in a loop. Re-using a sound sample object is much faster than\n\t\t\tcreating a new sound sample object from an array each time the sound\n\t\t\tshall be played.\n\t\t\t
\n\t\t\tSound | \n\t\t\t\tSound(buffers, sampleRate = null) \n\t\t\t\tconstructs a sound sample object. The parameter\n\t\t\t\tbuffers is an array of arrays containing the\n\t\t\t\tsamples to be played, or a string containing a data URI.\n\t\t\t\tThe second parameter sampleRate specifies the\n\t\t\t\trate at which the array samples are to be played in Hz. The sample rate\n\t\t\t\tshould be in the range 8000 Hz to 96000 Hz. If the first parameter\n\t\t\t\tis a data URI, then the sample rate is ignored.\n\t\t\t\tTypical channel numbers are one (mono) and two (stereo).\n\t\t\t |
---|
play | \n\t\t\t\tThe function play starts playing the sound.\n\t\t\t\tThe playback is asynchronous, meaning that the call returns immediately\n\t\t\t\tregardless of sound duration. Further instances of the sound can be\n\t\t\t\tplayed by calling the function again, even while the sound is still\n\t\t\t\tplaying.\n\t\t\t |
---|---|
startLoop | \n\t\t\t\tThe function startLoop() starts looping the\n\t\t\t\tsound, i.e., playing the sound repeatedly. The function returns\n\t\t\t\timmediately. In contrast to play , for each sound sample\n\t\t\t\tobject, only a single loop can exist at a time.\n\t\t\t |
stopLoop | \n\t\t\t\tThe function stopLoop() stops a sound loop\n\t\t\t\tthat was previously started with startLoop .\n\t\t\t |
looping | \n\t\t\t\tThe function looping() returns\n\t\t\t\ttrue if the sound loop is currently running, and\n\t\t\t\totherwise false .\n\t\t\t |
The following code plays two different tones on the left and right channels\n\t\t\tof a stereo device. l_freq
, r_freq
\n\t\t\tand sampleRate
can be modified to alter the tones.\n\t\t\t
The following code constructs a sound object from a data URI, representing\n\t\t\tmp3 encoded data. The sound is played three times.\n\t\t\t
event type: '+(0,r.escapeHtmlChars)(w[t].type)+" ";for(let n in w[t])w[t].hasOwnProperty(n)&&"type"!==n&&(e+=" "+(0,r.escapeHtmlChars)(n)+": "+(0,r.escapeHtmlChars)(JSON.stringify(w[t][n])));e+=" | ",l++}return e+="
Test case:
"+(0,r.escapeHtmlChars)(M.code)+"");break}}}c=0}n({error:i,details:o,points:c})}))},t}()},9395:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isRecursive=void 0;const r=n(8397),i=n(6025),a=n(5939),o=n(6676);e.isRecursive=function(t){return!!function(t){return!!t&&function t(e,n){if(e.builtin)return!1;if("breakpoint"===e.petype)return!1;if("function"===e.petype&&e.name){let t=n.slice();t.push(e.name),n=t}if("function call"===e.petype){if(e.base.name&&n.indexOf(e.base.name)>=0)return!0;if("this"===e.base.petype)return!0}for(let i in e){if(!e.hasOwnProperty(i))continue;if(o.reserved_node_names.hasOwnProperty(i))continue;let a=e[i];if(r=a,(Array.isArray(r)||function(t){return null!==t&&"object"==typeof t&&t.constructor===Object}(r))&&t(a,n))return!0}var r;return!1}(t,new Array)}(t)||function(t,e=3,n=[]){if(!t)return!1;n=n.slice();let o=new a.Interpreter(t,(0,i.createDefaultServices)());o.service.turtle.move,o.service.print=function(t){},o.service.alert=function(t){},o.service.message=function(t,e,n,r){},o.service.prompt=function(t){},o.service.turtle.move=function(t){},o.service.canvas.dom={width:1920,height:1080},o.service.canvas.clear=function(){},o.service.canvas.line=function(t,e,n,r){},o.service.canvas.rect=function(t,e,n,r){},o.service.canvas.fillRect=function(t,e,n,r){},o.service.canvas.frameRect=function(t,e,n,r){},o.service.canvas.circle=function(t,e,n){},o.service.canvas.fillCircle=function(t,e,n){},o.service.canvas.frameCircle=function(t,e,n){},o.service.canvas.curve=function(t,e){},o.service.canvas.fillArea=function(t){},o.service.canvas.frameArea=function(t){},o.service.canvas.text=function(t,e,n){},o.service.canvas.reset=function(){},o.service.canvas.shift=function(t,e){},o.service.canvas.scale=function(t){},o.service.canvas.rotate=function(t){},o.service.canvas.transform=function(t,e){},o.stopthread(),o.reset();let s=(new Date).getTime()+1e3*e;for(;;){let t=(new Date).getTime();if(t>=s)break;if("waiting"===o.status&&(o.status="running"),"running"!=o.status)break;for(;(new Date).getTime()-t<14&&"running"===o.status;){o.exec_step();let t=o.stack.length;for(let e=0;e
';for(let t=0;ti.length&&(o+=b(a.substr(i.length),e,n)),o+="\n")}for(;o.length>0&&"\n"==o[o.length-1];)o=o.substr(0,o.length-1);return o+="
';for(;!r.eof();){for(;r.good();){let t=r.current();if(" \t\r".indexOf(t)<0)break;" "==t?i+=t:"\t"==t&&(i+=" "),r.advance()}if(r.eof())break;let a=r.pos,o=n(r),s=t.substr(a,r.pos-a);s=s.replaceAll("&","&").replaceAll("<","<"),i+=''+s+""}return i+="
",i}}function w(t){let e=(0,d.parseProgramFromString)(t);if(!e.program)throw e.errors[0].message;let n=new c.Interpreter(e.program,(0,l.createDefaultServices)());for(n.reset(),n.service.message=function(t){throw t},n.service.documentation_mode=!0;"running"==n.status||"waiting"==n.status;)n.exec_step();"finished"!=n.status&&alert("code sample failed to run:\n"+t)}function x(t){let e=A(t);function n(){let t=!0;for(;e.good();){e.skip();let r=a(e);if(!r)return null;if("comment"!=r.type)if("grouping"==r.type){if(")]}".indexOf(r.value)>=0)return r;t||e.error("EBNF syntax error: operator or closing bracket expected"),null===n()&&e.error("EBNF: opening "+r.value+" not properly closed"),t=!1}else if("identifier"==r.type||"literal"==r.type||"special"==r.type)t||e.error("EBNF syntax error: operator or closing bracket expected"),t=!1;else if("operator"==r.type)t&&e.error("EBNF syntax error: expression expected before operator "+r.value),"="==r.value&&e.error("EBNF syntax error: assignment does not work here"),t=!0;else{if("delimiter"==r.type)return t&&e.error("EBNF syntax error: expression expected before semicolon"),r;e.error("unexpected token type in checkEBNF")}}return null}let r=!0;for(;e.skip(),e.good();){let t=a(e);if("identifier"!=(null==t?void 0:t.type)&&e.error("EBNF syntax error: left-hand-side must be an identifier"),e.skip(),!e.good()){if(r)break;e.error("EBNF syntax error: assignment operator '=' expected")}let i=a(e);if(!i)break;"operator"==i.type&&"="==i.value||e.error("EBNF syntax error: assignment operator '=' expected");let o=n();";"!=(null==o?void 0:o.value)&&e.error("EBNF syntax error: final semicolon expected"),r=!1}}function A(t){return{source:t,pos:0,good:function(){return this.possorry, no results found
";t.dom_content.innerHTML=o,t.dom_content.scrollTop=0,n="",r.update(i)}else try{let a=T(e),o=a[0],s=a[1],l=a[2],c=a[3],d="