Forloops in Askia Scripts 1.0 & 2.0


The article describes how to convert Askia Scripts 1.0 to Askia Scripts 2.0 for the four different types of forloops.

Applies to askiadesign
Written for Scripters and Data Processors

Forsum, Formin, Formax, Forset, For loops, Temporary variables, Scripts, Logic, Convert, Array, Number.

The file we will work through can be downloaded here: Forloops in Askia Scripts 1.0 & 2.0.rar. All the logical conditions are found in the routing mode of the .qes file.

Askia Scripts 2.0 have been around for a while now and were introduced as a much more powerful alternative to the scripting language already present in Askia Design, Scripts 1.0. It allows more flexibility and efficiency with the creation of temporary variables in the script, amongst other features.

Whilst Askia Script 1.0 can still be used, we recommend that you always use Askia Script 2.0 instead. This article aims to provide help in converting the remaining "legacy" script from 1.0 to 2.0.

The focus of this article is to show how to convert the 4 types of ‘forloop’ syntax in Askia Scripts 1.0 to their equivalent in Askia Scripts 2.0. The forloops are forsum, formin, formax and forset. Forset outputs an array (a set of numbers) whereas the other output one number. One main use of forloops is when you are required to write syntax which needs to check a condition over all the iterations of a loop.


  • Give me the number of each iteration of the loop (qloop) where a respondent has answered codes 4 or 5 at the coded question (q1) – for this I would use a forset to return a set of numbers.
  • Give me the highest number given across all iterations of the loop (qloop) where a respondent has answered the numeric rating question (q2) – for this I would use a formax to return the one highest number.


How to use the example .qex and explanation of the logical checks 


The .qex file has a number of questions grouped into chapters. There are eight chapters, two (script types) by four (loop types). I would recommend testing using fast screens mode so you can see the data being set into the variables as you proceed through the questionnaire:

The show variable at the start will let you select which of the eight chapters to test.

  • Forsum 1.0 & 2.0 –
    • The idea here is to check whether the majority of the statements in the loop have been answered negatively (Fair or Poor) and if so ask the follow-up open ended question.
  • Formin 1.0 & 2.0 –
    • The idea here is to check the minimum code given across the 10 iterations of the loop. Minimum possible code being 1 (Excellent). This is stored in the minrating
    • Once we confirm the minimum code, we check all iterations of the loop to see which have this minimum code. These iterations are stored in the minstatements
    • Then we select one of the minimum statements at random and store this in the minrand1
    • Finally we ask a follow-up open ended question: “You rated ??minrand1?? as ??minrating??. Why do you say that?

  • Formax 1.0 & 2.0 –
    • this is doing the same as the Formin chapters beforehand but using the keywords for finding maximums instead.
    • The other differences are that in Formax 2.0 there are two intermediate variables (maxrating2 & maxstatements2) removed. They are not needed because with Askiascripts 2.0 you can define temporary variables in your code thereby making you questionnaire structure and code cleaner and more efficient than previously.
    • Removing these variables mean we have to adjust our text substitutions as well:

  • Forset 1.0 & 2.0 –
    • The idea here is to check all the iterations and return into the fairpoor variable, all the iterations where the respondent has rated negatively (Fair or Poor).

Remember if you are writing any repetitive routing in Design then it can probably be re-written using forloops. If you have any questions when faced with that situation or about this article then please contact Askia support for guidance.

Have more questions? Submit a request