×
Menu
Index

Structure

 
A TBScript file consists of one or more subroutines. All scripts must define one subroutine called MAIN. Execution starts at this subroutine. Any subroutine can return a value using the RETURN keyword.
 
// Here is a sample script.
// Text that follows // or ; are comments and
// are ignored by the interpreter.
// Execution begins at the following subroutine
sub main()
     printl(double(5))
end sub
 
// Here's another subroutine. It returns the
// argument value times two
sub double(val)
     return val * 2;
end sub
 
This example defines two subroutines, main and double. Double accepts an argument and returns that value times two. Main passes 5 to double and prints the result.
 
Subroutines are called by specifying the name of the subroutine followed by parentheses. If the subroutine takes arguments, they can be specified between the parentheses separated by commas. Subroutine calls may be included in expressions or assigned to a variable, or even used as arguments to other subroutines.