Navigation:  Commands > Conditional and Loop Commands >

Conditional Processing Examples

Previous pageReturn to chapter overviewNext page

CopiaFacts supports conditional processing of most command files, but their principal use is in infobox (.IIF) files. Conditional commands are most useful in connection with $type decision infoboxes which are used to analyse responses to IVR prompt messages, but have many other applications also.

Other advanced uses of conditional processing are described in the CopiaFacts Scripting entry in the Features section.

Note that the conditionals in .FS files are processed when the file is first read by CopiaFacts; the .FS files written back into the SENT, FAIL and (for retries) TOSEND directories will reflect the conditional processing which occurred on first reading of the file.

All values and filenames on these commands are subject to macro-expansion using the normal @ syntax. Examples:

$if 06/93 $in @sys_date2

  ...

$endif

 

$ifn @myvar1 = @myvar2

  ...

$endif

$if @class > 100

  $next_box 2345

$else

  $next_box 1234

$endif

$ifn X $in @class

  $image_password dist.ndx 2

$endif

Parameters for comparison must not be surrounded by double-quotes; the double-quotes are not stripped before the comparison is done.  To test for a constant value with embedded spaces, assign it first to a variable:

$set_var testname "My Name"

$if @namevar = @testname

...

Conditional commands may be nested up to 32 levels deep. The proper terminating $endif commands must always be supplied. For example:

$if @myvar1 = foo

  $if @myvar2 = bar

    ...

  $else

  ...

  $endif

$else

  $ife @FFBASE\images\@mynum.TIF

    ...

  $endif

$endif

Indenting your $if commands as shown makes it much easier to balance the $else and $endif statements.  The COPIAEDIT program can automatically indent conditional commands (press F9).

IMPORTANT: Any variable set by a $get_var command will not have its value available for testing in the same .IIF file. This is because the user interaction to set the variable does not occur until after the first infobox has been completely processed. To test a value which has been input by the caller, use $next_box to transfer control to a new $type decision infobox, in which you can use the appropriate $if statements. For example:

;infobox 9123

$type question

$image_desc standard

$get_var varname2 3 5

$if @EXPERT = Y

  $validate none

$else

  $validate digits

$endif

$next_box 9000

 

;infobox 9000

$type decision

$if @varname1 = @varname2

  $next_box 2222

$else

  $next_box 3333

$endif

There is one more potential problem with constructing conditional statements in .IIF files: if you have ever done any computer programming, you may be tempted to treat $next_box like a "go to", which it is not. The following example illustrates this error:

;infobox 777 *** incorrect example ***

$type decision

$if @value = 23

  $next_box 2300

$endif

$next_box 4567 ; this line must be in an $else group

In the above example, when the value is 23 control does not immediately transfer to box 2300. Instead the 2300 gets overridden by the 4567 when the second $next_box command is processed. The correct way to construct this type of .IIF file is shown in the example infobox 9000 above.

 


Topic url: http://www.copia.com/support/refmanual/index.html?conditionalprocessingexample.htm