My conditions aren't working!!!

To err is human!

Many cases of "malfunctioning" conditions are due to inadvertent mistakes with syntax. Listed below are a few questions you should consider whenever you find a condition is not returning the result you expect.

1. Did I have the Interview Variables and Interview Script Windows open while I was previewing/testing my interview?

2. Did I check all references to variables for spelling errors?

3. If writing conditions within a repeat dialog ask, did I append all variables with the appropriate repeat variable (e.g., "#RepeatCount")?

4. Am I using the right syntax?

5. Did I write my AND and OR statements in the right order?

SYNTAX REMINDERS:

References to variables which include spaces must be enclosed within brackets, as follows: [Variable name TE]

References to variables within a function must be enclosed within parentheses (and brackets if the variable includes spaces), as follows: AGE([Variable name TE])

A few notes about quotations: Quotes need to be placed around variable values previously set, where the value was set as 
1) a default variable value; 
2) a multiple choice variable value; or, 
3) a "quasi" true/false variable used in the context of a button choice.

For instance, assume you set the following values for variables in a multiple choice selection:

For State MC, you provide several states as multiple choice options in a drop down list. If you want to write a condition based on a particular multiple choice selection, the condition would use the following syntax: IF State = "California" THEN.....

Also, consider the values set by a variable used in a button choice selection. A2J Author® allows an author to provide up to three buttons. So, naturally, the "Button" is not a true true/false mechanism, though you can set a variable behind a button choice to have a value of true or false. Assume you set the following values for a "quasi"-true/false variable used in the context of button clicks:

For the button labeled Married, you set Married TF to equal true. 
For the button labeled Not Married, you set Married TF to equal false. 
If you want to write a condition based on the button selection, the condition would use the following syntax: 
IF [Married TF] = "true" THEN.....

However, if a true/false variable is set to true or false based on a checkbox selection then no quotes are needed when referencing the variable value in a condition.

So, for instance, if you provided a checkbox selection, instead of a button click, to set the variable Married TF, then quotes do not need to placed around the variable value true and false in a condition statement. The correct syntax is as follows: 
IF [Married TF] = true THEN.....

Finally, remember the correct order and syntax for your AND's and OR's! 
1. AND's should be placed ahead of the OR's 
2. OR's statements should be wrapped within parentheses

Example: CONDITION: AGE([Child birth DA#ChildCount])<18 and ([Variable MC#ChildCount] = "Value1" or [Variable MC#ChildCount] = "Value2" or [Variable MC#ChildCount] = "Value3")

Note all variables with spaces are wrapped in brackets; the counting variable has been appended to each variable; the variable within the function is wrapped within parentheses; and, the entire set of OR statements is wrapped within parentheses.

If you have other helpful hints for troubleshooting please send them via A2J Author's Send Feedback button or post to this website. Thank you.