6. Basic System Calls
Basic System Calls are useful functions (like the echo function) that are defined in the essentials.gsl. This file is included automatically, so you don't have to include it if you wish to use one of these functions. System Calls refer to internal JAVA functionalities (that's why I called 'em system calls), they are only partly written in GSL. They are of such a great use that you should know them. So I list them here: Declaration: string echo(string message)
This function prints the string <message> onto the console and returns it. Useful for debugging purposes or status reports. Declaration: string echoln(string message)
Does the same thing like echo, but adds a new line character after message. Declaration: string warn(string message)
This function prints the string <message> onto the console as a warning (highlighted) and returns it. Useful for debugging purposes or status reports. Note that it adds new line after <message>. Declaration: void fail(string message)
The fail function immediatly stops script execution by throwing an error with message <message>. It can be used to stop the script in case of malicious input. Declaration: void sleep(int millisec)
Sleep stops the script execution for <millisec> milliseconds. Declaration: void include(string fileName)
Include loads and executes the script file <fileName>. It searches for the file in the following folders:
If the script file isn't found an error is thrown. If include is called more than once for a file, then it is only included the first time include is called for it. So you don't have to care, if a file is included somewhere else. If you need it, you can just include it. Declaration: void eval(string code)
Eval executes the string <code> as gsl code. Declaration: int size(array ary)
Size returns the size of an array <ary>. I.e. the number of int-keys + the number of string-keys. Declaration: var clone(var i)
Clone takes arbitrary data (except object) and returns a flat copy of it. So: if <i> is of type int,string,float,boolean i is just returned. if <i> is of type struct or array a new instance of the type of <i> is created and all members/key-value-pairs are copied to the new one. This can be used for by value calls of arrays and structs (See also: By Reference / By Value). |