Variables in Event Scripts
Variables are declared, set and get with functions. There are no variables like in Pascal or C that can be used just by writing their name. Variables are global, i.e. you can set a variable in one event handler script and use it in another. You can even set a variable in one report and use it in a second report executed afterwards. Variables are not initialized to some value when a report is generated.
To set a variable, use the SETVAR function with variable name and variable value as parameter. SETVAR automatically creates a new variable if it doesn't exist, else it will overwrite the value of the given variable.
SETVAR('Temp','This is a test string')
SETVAR('Num',1000)
SETVAR('Flag1',TRUE)
To get a variable value, use the GETVAR function with the variable name as parameter. The result type of GETVAR depends on what kind of variable (string, number, boolean) has been created/set with SETVAR.
GETVAR('Temp')
IF (GETVAR('NUM')>0)
RETURN(FALSE)
EXIT
ENDIF
SETVAR('Num',GETVAR('Num')+1)
SetStringProp('QRLabel1',GETVAR('Temp')+' !!!')
To check if a variable exists (i.e. has been created with a first call of SETVAR), use the VAREXIST function with the variable name as parameter.
IF (VAREXISTS('Flag1'))
:
:
ENDIF
To delete a variable from memory, use the DELETEVAR function with the variable name as parameter. VAREXISTS will return FALSE for this variable afterwards.
DELETEVAR('Temp1')