Sawtooth Software: The Survey Software of Choice

SSI Script Functions Inside Perl

I have the below script where I want to return options selected from dropdown box. If respondents select other specify, the 29th item, then it needs to display the text they entered. But my code is not working. What is the mistake?

[% begin unverified perl
if(VALUE("Q5A1_r1_c1") le 28) {return [%Label(Q5A1_r1_c1)%];}
if(VALUE("Q5A1_r1_c1") eq 29) {return [%Q5A1_r1_c2%];}
end unverified %]

There are a couple of things going wrong here. First, embedding SSI Script functions inside Perl requires close attention to capitalization. Whenever you are using SSI Script within Perl, the function name will almost always be capitalized. You can see this in the SSI Web Help files, under Unverified Perl Functions. There you will see a table that lists SSI Script and their Unverified Perl equivalents.

Second, keep in mind that many of our SSI Script functions are already Perl functions, so the [% ... %] is not necessary. In fact, it will generate an error if you try to embed them within each other. Instead, leave off the internal [% ... %] characters.

Here is the corrected code:

[% begin unverified perl 
if(VALUE("Q5A1_r1_c1") le 28) {return LABEL("Q5A1_r1_c1");} 
if(VALUE("Q5A1_r1_c1") eq 29) {return VALUE("Q5A1_r1_c2");} 
end unverified %]

Sawtooth Software

6:30 AM to 5:30 PM Mountain Time
(GMT-6; GMT-7 Autumn/Winter)
Monday through Friday

Phone: +1 801 477 4700
Fax: +1 801 434 5493
Email: support@sawtoothsoftware.com

We are open!

SKIM Software

9:00 AM to 5:30 PM Central European
(GMT+2; GMT+1 Autumn/Winter)
Monday through Friday

Phone: +31 10 282 3500
Fax: +31 10 282 3560
Email: software@skimgroup.com
Online: www.skimgroup.com

Lighthouse Studio

Lighthouse Studio is our flagship software for producing and analyzing online and offline surveys. It contains modules for general interviewing, choice-based conjoint, adaptive choice-based conjoint, adaptive choice analysis, choice-value analysis, and maxdiff exercises.

Try Lighthouse Studio

  Buy Lighthouse Studio