ASIS: Distinguishing Between Space and Zero

How to:

Reference:

Available Languages: reporting

The ASIS function distinguishes between a space and a zero in Dialogue Manager. It differentiates between a numeric string, a constant or variable defined as a numeric string (number within single quotation marks), and a field defined simply as numeric. ASIS forces a variable to be evaluated as it is entered rather than be converted to a number. It is used in Dialogue Manager equality expressions only.

Syntax: How to Distinguish Between a Space and a Zero

ASIS(argument)

where:

argument

Alphanumeric

Is the value to be evaluated. Supply the actual value, the name of a field that contains the value, or an expression that returns the value. An expression can call a function.

If you specify an alphanumeric literal, enclose it in single quotation marks. If you specify an expression, use parentheses, as needed, to ensure the correct order of evaluation.

Example: Distinguishing Between a Space and a Zero

The first request does not use ASIS. No difference is detected between variables defined as a space and 0.

-SET &VAR1 = ' ';
-SET &VAR2 = 0;
-IF &VAR2 EQ &VAR1 GOTO ONE;
-TYPE VAR1 &VAR1 EQ VAR2 &VAR2 NOT TRUE
-QUIT
-ONE
-TYPE VAR1 &VAR1 EQ VAR2 &VAR2 TRUE

The output is:

VAR1 EQ VAR2 0 TRUE

The next request uses ASIS to distinguish between the two variables.

-SET &VAR1 = ' ';
-SET &VAR2 = 0;
-IF &VAR2 EQ ASIS(&VAR1) GOTO ONE;
-TYPE VAR1 &VAR1 EQ VAR2 &VAR2 NOT TRUE
-QUIT
-ONE
-TYPE VAR1 &VAR1 EQ VAR2 &VAR2 TRUE

The output is:

VAR1 EQ VAR2 0 NOT TRUE

Reference: Usage Notes for ASIS

In general, Dialogue Manager variables are treated as alphanumeric values. However, a Dialogue Manager variable with the value of '.' may be treated as an alphanumeric value ('.') or a number (0) depending on the context used.

  • If the Dialogue Manager variable '.' is used in a mathematical expression, its value will be treated as a number. For example, in the following request, &DMVAR1 is used in an arithmetic expression and is evaluated as zero (0).
    -SET &DMVAR1='.';         
    -SET &DMVAR2=10 + &DMVAR1;
    -TYPE DMVAR2 = &DMVAR2             

    The output is;

    DMVAR2 = 10
  • If the Dialogue Manager variable value '.' is used in an IF test and is compared to the values ' ', '0', or '.', the result will be TRUE even if ASIS is used, as shown in the following example. The following IF tests all evaluate to TRUE.
    -SET &DMVAR1='.';
    -SET &DMVAR2=IF &DMVAR1 EQ ' ' THEN 'TRUE' ELSE 'FALSE';
    -SET &DMVAR3=IF &DMVAR1 EQ '.' THEN 'TRUE' ELSE 'FALSE';
    -SET &DMVAR4=IF &DMVAR1 EQ '0' THEN 'TRUE' ELSE 'FALSE';
  • If the Dialogue Manager variable is used with ASIS, the result of the ASIS function will be always be considered alphanumeric and will distinguish between the space (‘ ‘), zero (‘0’), or period (‘.’), as in the following example. The following IF tests all evaluate to TRUE.
    -SET &DMVAR2=IF ASIS('.') EQ '.' THEN 'TRUE' ELSE 'FALSE';
    -SET &DMVAR3=IF ASIS(' ') EQ ' ' THEN 'TRUE' ELSE 'FALSE';
    -SET &DMVAR4=IF ASIS('0') EQ '0' THEN 'TRUE' ELSE 'FALSE';
  • Comparing ASIS('0') to ' ' and ASIS(' ') to '0' always evaluates to FALSE.