Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Perl Script help

I am computing a new variable from existing multiple response questions. However, the system shows error in 'IF' statement line. Can  anyone help me what is the mistake in the code?

Note: Q7 is placed in different page.


<input name="AQ_A1" id="AQ_A1" type="hidden" value="
[% Begin Unverified Perl
 if (VALUE("Q7_1")==1 {return 1;}
 elsif (VALUE("Q7_1")==0 {return 0;}
 elsif (VALUE("Q7_16")==1 && (VALUE("Q7_17")==1 {return 0;}
 End Unverified %]"
>

asked May 1, 2014 by anonymous

2 Answers

0 votes
 
Best answer
The code is missing the closing parenthesis for the IF statements.  It should be
[% Begin Unverified Perl
 if (VALUE("Q7_1")==1) {return 1;}
 elsif (VALUE("Q7_1")==0) {return 0;}
 elsif (VALUE("Q7_16")==1 && (VALUE("Q7_17")==1) {return 0;}
 End Unverified %]"
answered May 1, 2014 by Mike Lodder Gold (23,410 points)
Thank you Mike!
0 votes
There is a syntax error.

Add ")" to close if statements as:

if (VALUE("Q7_1")==1) {return 1;}
answered May 1, 2014 by Saurabh Aggarwal Gold (27,930 points)
...