Miscellaneous

This section describes AskiaScript version 1, which has been superseded by AskiaScript 2.0.

 

FindIndexIn(,)

FindIndexIn(set, value)

This keyword returns the position of a specific value in the specified set. For example, FindIndexIn ( { 1; 5; 3} , 5 ) will return 2. This is useful to when transforming a question using entry codes into index.

ForMax(,,)

ForMax(VariableString, NumberOfIterations, Iteration)

This keyword allows you to create loops in Askia scripts and to find the maximum values.

For example:

ForMax( "j", 10, ??q1??[j] ) finds the maximum value of q1 in its 10 first iterations

You can also nest loops.

ForMin(,,)

ForMin(VariableString, NumberOfIterations, Iteration)

This keyword allows you to create loops in Askia scripts and to find the minimal values.

For example:

ForMin( "j", 10, ??q1??[j] ) finds the minimum value of q1 in its 10 first iterations

You can also nest loops.

ForSet(,,)

ForSet(VariableString, NumberOfIterations, Iteration)

The ForSet keyword allows to create loops in Askia scripts and to transform the values in a set.

For example:

ForSet( "item", 3, item ) is equivalent to {1} + {2} + {3} = {1;2;3}

ForSet( "j", 2, ??q1??[j] ) if q1[1]=3 and q1[2]=5, is equivalent to {3} + {5} = {3;5}

You can also nest loops

ForSum(,,)

ForSum(VariableString, NumberOfIterations, Iteration)

The ForSum keyword allows you to create loops in Askia scripts and to find the sum of all iterations.

For example:

ForSum("i",  3, 1) is equivalent to 1 + 1 + 1

ForSum("Index",  3, Index) is equivalent to 1 + 2 + 3

ForSum( "j", 10, ??q1??[j] ) find the sum value of q1 in its 10 first iterations

You can also nest loops.

ForSum("i",  3, ForSum (  "j", 5, j  ) )

IsUKPostCode ()

This keyword tests whether the specified item is a valid UK Postcode, and returns true or false as appropriate.

For example:

IsUKPostCode("L1 4AB")

On(, -)

Use this function to specify values resulting from the evaluation of the specified condition. The function specifies a condition, followed by values to be given if the condition evaluates True or if False.

For example: we have a single-coded closed question called Q1, containing response items: A, B and C. The following syntaxes are possible:

On(??Q1??,10,20,30)

meaning that if answer A has been selected the value 10 will be returned, if answer B has been selected the value 20 will be returned, etc.

 

On(??Q1??=1, 10, 0)

meaning that if answer A has been selected the value 10 will be returned, otherwise if answer A has not been selected value 0 will be returned.

 

On(??Q1??=2, "Knowing that you use B", "Imagining you use B")

meaning that if answer B has been selected the text value "you selected B" will be returned, otherwise if answer B has not been selected text value "you did not select B" will be returned.

Random()

Use this function to randomly select values. For example, you might randomly select response items:

Random(5)     returns 1 value among: {1; 2; 3; 4; 5}.

Random({5; 10})          returns 5 values among: {1; 2; 3; 4; 5; 6; 7; 8; 9; 10}.

SelectRandom( ,1)

Use this function to randomly select a specified number of values from an existing set of values.

For example:

SelectRandom({5 To 10}, 3)

the function will randomly select three values from 5, 6, 7, 8, 9 and 10 (e.g. 5, 6, and 9).

 

SelectRandom(??Q1??, 5)

the function will randomly select five values among those which have been given by the respondent to Q1.

Shuffle()

Use this function to sort a list of items into a random order. This can be a list of items, expressed as a set, or the answers to a question.

For example, if we define a routing of type set value, and in the field value if true, enter the following expression:

Shuffle({1 To 5})

The function will return the values 1 to 5 in random order (e.g. 4, 5, 2, 1, 3).

Shuffle("Q1")

The function will return the answers to the variable with shortcut Q1 in a random order.

SetMaxRun()

We need a detection of an infinite loop. For that, we would stop the execution of any routing after 2,000,000 runs.

We have added the SetMaxRun to all Askia scripts to indicate when that error should occur.

If you call SetMaxRun(-1) the detection of infinite loops will be disabled... this is dangerous in a live environment!

The development was originally done for Analyse

Chr()

Added in design 5.6.1:

returns a string

Chr returns the character associated to the ASCII (or unicode) number
example chr(9)  returns tab.

Asc()

Added in design 5.6.1:

returns a number

Asc returns the ASCII number of the first character of a string, 0 if the string is empty.

example Asc(chr(9))  returns 9.

 

 

 

 

 

 

 

Create your own Knowledge Base