The HotDocs Computation Archive
Get Extra Help

0044 - ANSWERED( Variable[x] )

Description:

How to test for an ANSWERED variable at a specific counter level.


• Code •

Preferred Methods:

SET Temp-n TO NumVar[3]
ANSWERED( Temp-n )

SET Temp-t TO TextVar[3]
ANSWERED( Temp-t )

SET Temp-d TO DateVar[3]
ANSWERED( Temp-d )
 
 
SET Temp-n TO NumVar[3]
IF ANSWERED( Temp-n )
   // Do something
ELSE
   //Do something else
END IF

SET Temp-t TO TextVar[3]
IF ANSWERED( Temp-t )
   // Do something
ELSE
   //Do something else
END IF
 
 
Different Method:

(must be used exactly like this):

FALSE
IF TextVar[3] > ""
   TRUE
END IF

FALSE
IF NumVar[3] <= 0 OR NumVar[3] > 0
   TRUE
END IF

FALSE
IF DateVar[3] > 01 JAN 1582
   TRUE
END IF
 
 
Loooong Way:

FALSE
REPEAT RepeatedDialog 
   // Set COUNTER to the level you're curious about
   IF COUNTER = 3
      ANSWERED( Variable )
   END IF
END REPEAT

• Explanation •

Problem. HotDocs will not allow you to test whether a specific iteration of a REPEATed variable is ANSWERED: IF ANSWERED( Variable[x] ) ...

Solution #1 (Preferred). SET the value of Variable[x] to a temporary variable, then test whether that variable is ANSWERED. This technique relies on the fact that if VarA is UNANSWERED and you SET VarB TO VarA, VarB becomes UNANSWERED as well. Note also that since this takes place outside of a REPEAT, you can put this computation within any other REPEAT without having to worry about nested REPEAT issues. (Contributor: Lee Knight)

Solution #2. Rather than testing whether your variable is ANSWERED, just check whether it has a value. For example, you can see if TextVar[2] > "", or, in other words, whether TextVar has some value greater than empty. You can similarly test other variable types, as demonstrated above (see also Computation #0069: Alternatives to IF ANSWERED).

Caveat: These scripts must be used exactly as they are or the computation will fail. The initial FALSE sets the default value for the analysis. When HotDocs then tests IF TextVar[3] > "", it will either get a TRUE value or an ***Unanswered*** value (NULL). In the case of the NULL value, RESULT will fall back to the initial FALSE for its return value. So the computation will indeed return TRUE if the variable is answered, and FALSE if it is not. The following script, however, will fail if the variable is unanswered:

IF TextVar[3] > ""
   // Do something
ELSE
   // Do something else
END IF

If TextVar[3] is unanswered in this scenario, HotDocs will skip the entire IF block, including the ELSE section. That is because the IF analysis did not return TRUE or FALSE - it returned NULL. Hence, HotDocs cannot determine which statement to execute and aborts the whole sequence.

Solution #3. Test the iteration you are interested in from within a REPEAT block. While this is by no means pretty, the technique is to create a TF computation which runs to that particular iteration of the REPEAT, then checks the variable. In the code above, you would set COUNTER = 3 to the level you are curious about. When the REPEAT loop reaches that level, it checks the ANSWERED status of your variable. You could also set COUNTER = 3 to a variable which holds the level number (set in another computation). For example, COUNTER = Temp-n , where Temp-n is a temporary number variable.

 

• Contributors •

Lee Knight
Consultant
(619) 255-4986
(Home Page)
  LegalCS