The <_if> tag is similar to the <_call> tag except that it allows comparisons to be done against
the return value of the command called. This tag may be used to perform simple logic within LeXml markup pages
to determine what parts of the pages are parsed or ignored. See also the <_else> and <_endif> tags.
Body of the <_if> tag:
The body of the <_if> tag consists of a series of argument=value pairs
seperated by carriage returns or "\n". The body is optional; some commands may not require any arguments. The value
portion of each argument=value pair may consist of a simple string, a variable, or a if to another command
to get it's return value.
Attributes of the <_if> tag:
expr=<expression> (Required)
The expr attribute contains the if expression to be used to evaluate the return value of the command or
the variables mentioned in the expression. (Note that <_if> can be called without any name or cmd
attributes to compare two variables or to compare a variable against a string.)
Expressions are:
[(value1)(operator)(value2)](& or |)[...]
Brackets are only required if you are using & or |, so you could
also have just (value1)(operator)(value2).
Operator can be one of: =, !=, <, >, <=, >=, ^, and !^ which are equals,
not equals, less than, greater than, less than or equals, greater
than or equals, contains string, and does not contain string.
Value1 and value2 can be literal values or variable expressions.
The value (!) will be replaced by the return value of any command
that was called in the if statement. You don't have to call a command,
in which case (!) will be the same as (). The parentheses are always
required.
name=<name of the module instance to call from> (Optional)
The name attribute is the name of the module instance to call. This is the name that you assigned in the<_load> tag.
cmd=<command name> (Required if name is also present)
The cmd attribute is the name of the method within the interface module to call. (The actual methods in
the Java objects representing interface modules are called CMD_commandname, see Writing Interface Modules.)
quiet=<yes/no> (default=yes) (Optional)
If the quiet attribute is set to 'yes' then no output will be produced by this command to the http output
stream. This is the default behavior for the <_if> tag.
Examples of the <_if> tag:
<_if name="modulename" cmd="modulecommand" expr="(!)=(yes)">
arg1=This is the first argument
arg2=$var1:default value if var1 does not exist
arg3=$var2
arg4=!util:getsession:var=somesessionvar
</_if>
This would be true if modulecommand returns "yes".
<_if name="itembrowser" cmd="totalitemcount"
expr="(!)=(0)"/>
This would be true if the totalitemcount command returns 0.
<_if expr="($emailaddress)^(@)"/>
This would be true if the string "@" is found in the variable $emailaddress.
<_if name="util" cmd="gethttpheader"
expr="(!)^(MSIE)">name=User-Agent</_if>
This checks for an Internet Explorer compatible browser (see If_Utils for more information on these type of commands).
<_if expr="($startat:-1)=(-1)"/>
This would be true if the variable $startat is -1 or does not
exist (since $startat:-1 will evaluate to -1 if $startat doesn't
exist).
<_if name="util" cmd="getSession"
expr="[(!)!=(0)]&[(!)!=()]>var=ordid</_if>
This would be true if the session variable ordid is not 0 and is not empty
or null. Notice the brackets-- they are only required if you are doing an and
or or grouping of more than one expression.
<_if expr="($test)=()"/>
Test is null or empty.
<_if expr="[($ord_id:0)>(10000)]|[($ord_id:0)<(0)]"/>
$ord_id > 10000 or < 0 (with default being 0 if ord_id is not
defined).
<_if name="order" cmd="getrefid" expr="(!)>=(12000)"/>
Is ord_refid >= 12000?