Related Information Examples & Tutorials
Your server is the heart of your company and it's health is vital to the functioning of your business. Schedule a Server Analysis to help keep your system tuned up and running optimally. Not an Extended Support Member but would like to explore custom consulting services? Contact us for pricing.
“ Web Host and word of mouth is how we get our new clients these days. ” Norma B.

How To Use The If Conditional

In your report definition, you may want to assign a value to a variable only when a certain condition is met. For instance, if the debtor's owing is less than $50, you may want to output a line of text in your report. To do this, you can place an If Statement after a variable declaration, and the assignment will only occur if the condition is true.

tip.gif The If Statement can also be used in Control Files to change a field label or assign a value when a certain condition is met. Please see How To Use Control Files for details.


- Familiarity with use of the Report Writer
- Review How To Use Variables

tip.gif Please be aware that with loops, we use the WHERE clause to set conditions. Although the report writer evaluates the If Statement in a similar way, the If Statement is used to assign a value to a single variable. It is not used in the loop syntax.

Top of page.

Examples Of If Statements

After your variable has been declared and initialized, you can assign a value to it using an If Statement.

Each If Statement must start at the beginning of the line in the report writer. Do not indent or it will not work.

tip.gif One complete statement should be printed on a single line. The following statements have been spread over two lines for printing and display purposes in your browser. When you use them in your own code, please put the entire statement on a single line and DO NOT INDENT in the report writer.

Example 1:

@varTotalPrincipal = if ( = Active)

Example 2:

@varTotalPaid =
@( if ( = Closed)

Example 3:

@varTotalDirect =
@(varTotalPaid+tr.di) if (@tr.ty = 104)

Example 4:

@varString1 =
owes less than $100.00 if (@de.ow < 100)

Top of page.

Clearing A Text String With If

This example clears a text string variable.

@varString1 =    if (@de.ow < 1)

Top of page.

Changing A Field Value With If

This example will change the debtor's status to SKP if the Address is not OK.

@EDITde.sta = SKP if ( = " ")

Top of page.

Include With If Statements

You can use IF statements with the @include command to load files conditionally when your report prints.


@include header1.txt if ( = 92 )

@include header2.txt if ( = 98 )

@include header3.txt if ( = 101 )

This example loads a different header file depending on the Debtor's Client.

Please refer to Help topic, How to Use @Include in Reports.

Top of page.


To understand the concept of Variables used in these code snippets, please refer to How To Use Variables.

Top of page.

See Also

- Report Sample to view sample reports and letters
- Report Topics Index for a list of all report and letter topics

Top of page.

Was this page helpful? Do you have any comments on this document? Can we make it better? If so how may we improve this page.

Please click this link to send us your comments:

RMA RMA Canada ACA Member