top of page

69. Alternatives to IF ANSWERED

Description

Other ways to test whether a variable has an answer.

Code

Text Variable:

(in islolation)

IF TextVar > ""

(as a true/false computation)

FALSE
IF TextVar > ""
TRUE
END IF


Date Variable:

(in islolation)

IF DateVar > DATE OF( 1, 1, 1582 )

(as a true/false computation)

FALSE
IF DateVar > DATE OF( 1, 1, 1582 )
TRUE
END IF


Multiple Choice Variable:

(in islolation)

IF MCVar > ""

(as a true/false computation)

FALSE
IF MCVar > ""
TRUE
END IF


Number Variable:

(in islolation)

IF NumVar <= 0 OR NumVar > 0

(as a true/false computation)

FALSE
IF NumVar <= 0 OR NumVar > 0
TRUE
END IF

Explanation

There are occasions where IF ANSWERED( Variable ) is not the best approach. For example, IF ANSWERED( Variable ) will not ask the variable being tested. So if you use IF ANSWERED( DateVar ) in a computation, HotDocs will not ask DateVar and then check it for an answer, but rather will just test the current state of DateVar.

An alternative to IF ANSWERED is to use one of the constructions above. A description of each follows.

Text Variables. Text variables are tested to see whether they have a value greater than nothing, or an empty string "". If the variable has any content at all, it will be greater than empty.

Date Variables. Date variables are tested by comparing them to the earliest date HotDocs will recognize: January 1, 1582. If DateVar has a valid answer, it will be greater than DATE OF( 1, 1, 1582 ).

Multiple Choice Variables. Multiple choice variables are essentially text variables with some preset answers. Therefore, they can be tested in the same way as text variables (but note the exceptions: Computation #0111: Multiple Choice Variable as a Text Value).

Number Variables. Number variables are tested by checking whether they have a value that is less than or equal to 0 or greater than 0. In other words, any valid number. If it has a valid number, it has been answered. Otherwise it has not.

True/False Variables. True/False variables cannot be tested in this way.

Caveat: If the variable is UNANSWERED, it can cause problems with the logic. An unanswered variable causes the entire IF block to be skipped, even the ELSE section (see Computation 70: Avoid ***Computation***). The "true/false computation" versions above avoid this issue by providing a default value first.

bottom of page