Lighthouse Studio

Sawtooth Script

Sawtooth Script is a scripting language that you can use within Lighthouse Studio.  You can use Sawtooth Script to write small sections of customized code that will enhance your web survey.  

 

Where can Sawtooth Script be Used?

Displaying Responses to Previous Questions

Functions

Unverified Perl

 


Where can Sawtooth Script be Used?

 

Sawtooth Script can be used in the following areas:

 

Skip Logic - In Skip Logic skips are executed if the Sawtooth Script that you provide evaluates to true.  If, for example, the expression:

 

((Q1 + 3) > Q2) And (Q5 < 8)

 

evaluates to true then the skip is taken.  Note that no beginning and ending [% %] Sawtooth Script tags should be used when specifying Sawtooth Script within Skip Logic.

 

List Building - Constructed lists are created by using Sawtooth Script List Functions.  For example:

 

AIC(Q1)

INSERT(5, ColorList)

 

Note that no beginning and ending [% %] Sawtooth Script tags should be used when specifying Sawtooth Script within List Building.

 

Inline – Inline scripting involves inserting sections of Sawtooth Script into your text or HTML.  To enter a section of Sawtooth Script into your text it must be wrapped by [% and %].  For example the following text could be entered into the header of a question:

 

Why do you spend [% (PhoneHours / TotalHours) * 100 %] percent of

your time at work on the phone?

 

Sawtooth Script is processed/executed on the server before it is sent down to the respondent's browser.  The script between [% and %] is executed and the result is inserted into its place.  If the respondent had answered 18 for the question PhoneHours and 40 for the question TotalHours, then the above text would be displayed to the respondent as:

 

Why do you spend 45 percent of your time at work on the phone?

 

Question Settings – You can enter Sawtooth Script in some question settings .  For example, the Total setting in a Constant Sum question accepts the answer to a previous question.  So, if [% Q1 %] were entered into the Totals field, then the respondent's answer to Q1 would be used as the total required for the Constant Sum question.  Note that beginning and ending [% %] Sawtooth Script tags are needed when specifying Sawtooth Script within question setting fields.

 

Quota Control – You can enter Sawtooth Script in the qualification logic that indicates whether a respondent qualifies to count toward a Cell Limit.  Note that beginning and ending [% %] Sawtooth Script tags should not be used when specifying Sawtooth Script within quota control qualification logic.

 

We admit that it might be confusing to remember when [% %] tags are needed or not when adding Sawtooth Scripting to your questionnaire--or whether Sawtooth Scripting is permitted at all in specific areas.  Fortunately, Lighthouse Studio will give you an error message if your syntax is incorrect.  When in doubt, just try using Sawtooth Script and then click the "Check" icon to have Lighthouse Studio check your syntax.  For example, it may tell you that the "[" character is not valid (which indicates that the tags are not needed).  If you see the pencil icon next to a field in Lighthouse Studio, that is an indicator that Sawtooth Scripting is permitted for that field.

 


Comments

 

You might find it useful to add comments to your Sawtooth Script.  To add a comment, use a single quote character prior to the comment text.  For example:

 

'Here I'm adding the items that were chosen

AIC(Q1)

 

or

 

[% 4 + Q1 'Here we are adding 4 to the answer to Q1 %]

 

Everything after the single quote on the same line (except for the closing "%]" ) is a comment and is ignored when the Sawtooth Script is executed.

 

Created with Help & Manual 8 and styled with Premium Pack Version 4 © by EC Software