You are here: Field Rules Reference > Field Rules Summary > If

If

Use this field level rule to get information from an extract file if certain conditions are met. In addition, the IF rule lets you call most of the DAL functions. For more information, see the FieldRule function in the DAL Reference.

You can specify a file name by adding &filename in the Data field.

The IF rule supports the FieldRule function to call every field rule in the IF rule. The FieldRule function requires as many parameters as are required for a field level rule. Not all fields must contain data, but you must include the correct number of delimiters.

Here is a list of field rule parameters. An asterisk indicates the parameter is generally required, depending on the rule you are using. If you leave a parameter blank, be sure to include two colons as delimiters (::) to indicate the parameter is blank.

Parameter

Description

File number

(required by TblLkUp)

Record number

(required for overflow)

Source field name

(required by TblText)

Source field offset

*

Source field length

*

Destination field name

*

Destination field offset

 

Destination field length

*

Format mask

*

Field rule name

*

Rule parameters

* (also called “data”)

Flag1

(also called “not required”)

Flag2

(also called “host required”)

Flag3

(also called “operator required”)

Flag4

(also called “either required”)

X position

 

Y position

 

Font ID

 

The IF rule and overflow

You can use overflow variables if the field level rule you used supports overflow. Generally, the IF rule does not support overflow—it can only be supported through the use of the FieldRule function. Here is an example. Suppose you want to move multiple lines of text from N number of specific external extract records to the output buffer when the HEADERREC record (at offset 11) contains an F in position 1.

For this scenario, you could use the FieldRule function to call the MoveExt rule and use the standard IF rule to do the rest. The DAL script for this example would look like this:

CON={11,HEADERREC 1,1}:: A=FIELDRULE("::0::1::E::45::4::PREM/OPS RATE1::0::4::::moveext::@GETRECSUSED,QCPVR5,OVSYM1/11,CLSSCDREC::N::N::N::N::::::::")::if(CON='F')::return("^" & A & "^")::end ;N;N;Y;N;12461;2119;16010

Overflow variables used in the search mask have a syntax which looks like this:

@GETRECSUSED,CPDEC1,CPDEC1OVF/11,CLSSCDREC

Writing DAL scripts

Keep in mind that writing DAL scripts is like coding rules. You must write the script using the correct syntax and make sure you correctly handle the variables you use. This table shows the different types of variables:

Type

Description

A

String variable. Use quotation marks for comparisons with this variable.

$A

Numeric variable with decimal places. Omit the quotation marks and include only numbers.

#A

Numeric variable without decimal places. Omit the quotation marks and include only numbers.

In an IF condition, the data type of the variable on the left side of the operator determines the data type used during the comparison. This means the variable/number/string on the right is converted to the data type of the variable/number/string on the left. After this conversion occurs, the comparison is performed.

If you encounter this error message:

DM10558: Error in GetFieldRuleData(): Condition exceeds buffer length

Use this statement:

CALL("logo.dal")

Using Curly Braces { }

You can use curly braces { } to tell the system to apply a search mask before executing the DAL script. Here is an example:

$A = {11,AUTONUREC 25,9}::

The use of curly braces is not part of DAL syntax, but rather is a Documaker Server notation that is preprocessed before the DAL script is executed.

Please note that you can only use curly braces in this manner if the DAL script is written into the rule data area. External DAL script files cannot contain such syntax. To retrieve extract data within an external DAL script file, you have to use the GETDATA function.

For more detailed information on writing DAL scripts and using DAL functions, see the DAL Reference.

See also