Macro Functions
Comments
Two types of comments are supported:
•
A comment begins with
/* and ends with
*/
. The comment can span any number of lines.
•
A single line comment begins with
//
and extends to the end of the line.
For example:
/* this is a comment */ var a
/* this comment
spans
multiple lines */ a = 0 // this is a comment to the end of the line
Strings
Strings must be enclosed in double-quote marks. Single quotes are not used. For example: a = "this is a literal string"
To embed a double-quote character in a string, you must escape it with a backslash character. For example: a = "Open the file \"test.txt\" to begin the test."
Semi-Colons at the End of Statements
Semi-colons are not required at the end of statements, but they are allowed and ignored.
Macro Functions
A macro function is declared in a format that looks like a C function. White space is ignored, and function and variable names are not case sensitive. A macro function begins with either the macro
or function
keyword, followed by the name of the function. Here is a most basic function: macro HelloWorld()
{
msg("Hello World!") // message box appears with "Hello World"
}
Macro functions can have parameters and can call other macros. You can return a value from a macro by using "return n" where n is the return value. For example: function add2(n)
{
return n + 2
}
User-Level Macros vs Functions
There are three flavors of macro functions:
•
User-level commands you can assign to a key or menu. These must be declared with the macro
keyword, and have no function parameters. The name of the command is the same as the macro function name.
•
Functions that are used as subroutines that you can call from other macro functions. These should be declared with the function
keyword.
•
Event functions that are used to hook into events. These are declared with the event
keyword. See
“Macro Event Handlers” on page 411.
366 Source Insight 4 User Guide