Referencing the Values of Variables
Variables may be tested using the $if and $ifn (if not) commands using the standard comparison operators as well as the $in operator to test for the presence of a sub-string. These commands are used with the $else, $elseif, and $endif commands to perform conditional comparisons and to execute blocks of code based on the results. The special commands $ife and $ifne may be used to test for the existence of a file and optionally that it is a minimum size. This gets around the problem in which the operating system creates a directory entry for a file before the file is actually written, and can also help to identify a 'real' message recorded by a caller. A scripting module which is used only to test and assign variables will normally be $type decision.
When using variables in comparisons or when assigning one variable to another, it is important to prefix the variable name with the @ character. This tells the script to use the contents of the variable. For example, if you write the following script line:
$if Myvar = 2 ; !! bad syntax
the comparison will always be false because you are comparing the literal string of letters 'Myvar' to the string '2'. You need to write the command instead as:
$if @Myvar = 2
This tells the script to compare the contents of the Myvar variable to 2. If both operands in a comparison are numeric integers, then a numeric comparison is performed. Otherwise the operands for '=' are compared as strings. You can force a numeric comparison for numbers with decimal positions by using the operators such as $eq described in the reference section $if.