Sawtooth Script

Top  Previous  Next

Sawtooth Script allows you to write small sections of customized code that can enhance your survey.  Sawtooth Script can be used in Skip Logic or entered into the text of any question.

 

Here is an example of Sawtooth Script in Skip Logic:

 

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

 

Q1, Q2, and Q5 will be replaced with the actual values entered by the respondent for those questions.  Then if the expression above evaluates to true the skip will be taken.  

 

If Sawtooth Script is used within question text then you need to surround the code with [% %].  For example:

 

[%Name%], welcome to the survey!

 

Sawtooth Script is evaluated on the server before it is downloaded to the web browser (unlike JavaScript that runs in the browser).  In the example above assume that the respondent had entered "John" as their name on a prior screen.  When the page runs on the server the Sawtooth Script will evaluate and:

 

John, welcome to the survey!

 

will be displayed on the respondent's screen.

 

Here is an example that uses Sawtooth Script functions (see functions below) to display a unique code to the respondent:

 

[% RespNum() * Power(10, 4) + RandNum(1, 1, 9999) %]

 

In the example above the respondents unique id is returned from "RespNum()".  Four zeros are then added to the end of the number by multiplying the number by 10 to the 4th.  Finally a random number from 1 to 9999 is added to the number.

 

Sawtooth Script Functions

 

System Functions

Math Functions

String Functions

CBC Functions

MaxDiff Functions

Quota Control Functions

Error Message Functions

 

 

 

Page link: https://www.sawtoothsoftware.com/help/discover/manual/index.html?script.html