General EQWatcher Concepts > Venturing into the Unknown  > Functions


An EQWatcher Advanced script function is a sequence of commands.  Functions have the scope of a single script, and no two functions can have the same name.  Functions can have parameters, local variables, and may return an integer type value (never a string).  Any function that has parameters MUST receive those parameters when it is called, or an error may occur.  The compiler generally makes sure this works correctly, but I'm sure someone will find a way to break it.  Functions may never have more than 9 parameters or 255 local variables.  For extremely large functions you may want to break them down into smaller functions. 

Functions are defined as follows:

function [name]([type 1] [name 1], [type 2] [name 2], . . . [type 3] [name 3])

{

[commands]

}

The first function of any script MUST be the "main" function, which is always run when the script is loaded.  This function takes 0 parameters and generally would not return a value.  Any function has the option of returning a value.

Here is an example of the main function definition:

function main()

{

string LocalVar1;

unsigned long LocalVar2;

}

This example of course has no commands, since you aren't to the commands section yet, but two local variables are defined. Again, local variables may not be made public.

Aliases and Triggers are defined as functions that may have NO parameters.  They are defined as follows:

alias("text to match")
{
}
 

and

trigger("text to match")
{
}
 

Please note that while trigger strings must account for the entire line from the log file, including the time stamp, aliases do not need to account for the header from the notes file.