The IF tag has the following format
Binary Conditions:
|
<IF VARIABLE="string1", OPERATOR="op", COMPARISON="string2"> lines of HTML code to be included if the condition is true </IF> |
Unary Conditions:
|
<IF VARIABLE="string1", OPERATOR="op"> lines of HTML code to be included if the condition is true </IF> |
where
|
string1 |
is a string expression. It can include alphanumeric characters and variables to be expanded (in {} brackets). | ||||||||||||||||
|
string2 |
is also a string expression. It can include alphanumeric characters and variables to be expanded (in {} brackets). | ||||||||||||||||
|
op |
is a comparison operator. Allowed values are:
|
The comparisons perform an exact string match and are case-sensitive. IF tags can be nested (placed within another tag). If the comparison is successful, the text between the <IF> and </IF> tags is included in the processing. If not, processing continues after the matching </IF> tag.
ELSE tags do not exist, since they are incompatible with SGML.
Some non-standard SGML markup is permitted by RES-Reach. For instance, the following example is allowed by RES-Reach but would not be allowed by an SGML parser:
< IF ... >
< DATA ... >
< /IF >
< IF ... >
< DATA ... >
< /IF >
< /DATA >
This syntax opens one database query under certain conditions, and another under other conditions. This type of syntax relies on the programmer to make the two conditions complementary to avoid opening two queries, or none.
Examples:
Example 1: Displaying default text from a file variable if a database field value is blank or unknown.
<IF VARIABLE=";{[Order.Status]};" OPERATOR="SS" COMPARISON=";;{Unknown};">
{@PURCH/currct30.eng}
</IF>
<IF VARIABLE=";{[Order.Status]};" OPERATOR="NS" COMPARISON=";;{Unknown};">
{[Order.Status]}
</IF>
Example 2: Selecting the appropriate database query based on the value of a form variable.
<IF VARIABLE="{USER_ORDER}" OPERATOR="EQ" COMPARISON="BY_DATE"> <DATA SQL="SELECT PO.*, VENDOR.VendorName FROM VENDOR INNER JOIN PO ON ([Vendor.VendorCode]=[PO.VendorCode]) ORDER BY PO.DeliveryDate;", DATABASE="{DB}/order.mdb", CONNECT="", MODE="READONLY", ALIAS="GetPO"> </IF><IF VARIABLE="{USER_ORDER}" OPERATOR="EQ" COMPARISON="BY_VENDOR"> <DATA SQL="SELECT PO.*, VENDOR.VendorName FROM VENDOR INNER JOIN PO ON ([Vendor.VendorCode]=[PO.VendorCode]) ORDER BY Vendor.VendorName;", DATABASE="{DB}/order.mdb", CONNECT="", MODE="READONLY", ALIAS="GetPO"> </IF><IF VARIABLE=";{USER_ORDER};" OPERATOR="NS" COMPARISON=";BY_VENDOR;BY_DATE;"> <DATA SQL="SELECT PO.*, VENDOR.VendorName FROM VENDOR INNER JOIN PO ON ([Vendor.VendorCode]=[PO.VendorCode]) ORDER BY PO.PONumber ASC;", DATABASE="{DB}/order.mdb", CONNECT="", MODE="READONLY", ALIAS="GetPO"> </IF> <RECORD> <!-- Display PO's --> PONumber: {[GetPO.PONumber]} Vendor Name: {[GetPO.VendorName]} Delivery Date: {[GetPO.DEL_DATE]} </RECORD> </DATA>
Example 3: A sample default.nbt file (see section 2.1.2)
<IF VARIABLE="{nbt}" OPERATOR="FI"> {@{nbt}} </IF><IF VARIABLE="{nbt}" OPERATOR="NF"> <IF VARIABLE="{path_info}" OPERATOR="FI"> {@{path_info}} </IF><IF VARIABLE="{path_info}" OPERATOR="NF"> File {nbt} not found. Check your spelling </IF> </IF>