-
Notifications
You must be signed in to change notification settings - Fork 0
Functions
A function can be called using FUNCTION_NAME()
.
Parameters can be added to the function call by putting a comma separated list inside the parentheses.
Some functions are built in, Only some will be Illustrated here, The others can be used via the libraries provided with the binary.
- count(map): Counts the number of elements in a map
- int(number or string): Returns the integer representation of a number or a string, if possible, raises an exception otherwise.
- string(number): The parody of int.
- map(): Returns a new empty map object.
- getPage(URL): Returns the HTML of the given URL.
- cmd(Command): Runs a CMD command.
- run(Path, Arguments): Runs an application in Path, with the supplied arguments.
- getFile(Path): Returns a string containing the contents of the file.
- saveFile(Path, Contents): Writes Contents to the file located at Path if it exists, Creates one and saves it otherwise.
- drawOnCanvas(image): draws an image on the GUI canvas, will be explained further.
- registerHandler(EventName, HandlerClass): Supplies that the HandlerClass can handler the EvenName, will be explained later.
- getTypeName(object): returns the type of a class object, will be explained later.
- getCurrentDirectory(): Returns a string containing the path of the directory of the Application.
Functions can be created using the function
or the func
keyword.
Syntax:
func FUNCTION_NAME(PARAMETER_NAME as PARAMETER_TYPE)
STATEMENTS
endfunc
The parameter type is optional, but recommended.
the parameter types can be any of:
- 'string'
- 'number'
- 'integer'
- A class name.
Functions can return any variable at any part, using return EXPRESSION;
.
If you need to access global variables and edit them, you'll have to use the global
keyword.
function FUNCTION_NAME(PARAMETER_NAME as PARAMETER_TYPE)
global VARIABLE_NAME;
endfunction
the global keyword must be used at the beginning of a function, multiple variables can be globalized using a comma separated list.
Functions can be overloaded to make multiple functions with the same name, but with different parameters (Note that types 'number' and 'integer' are considered the same).
function RunApplication(path as string)
cmd(path);
endfunction
function RunApplication(path as string, parameters as string)
run(path, parameters);
endfunction