String

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

 

Format(,)

Use this function to reformat a numeric value according to a specified format. In other words, the value of the function's second statement specifies the maximum number of decimals.

For example:

Format(??Q1??, 2)

if Q1= 3.14159265, then the function will return: 3.14.

 

Format((??Q1??+??Q2??)/3, 5)

if Q1=1 and Q2=3, the function will return: 1.33333.

 

Note: If you would like to use this function in a numerical question, use val(Format(??Q1??, 2)).

GetParameter("",)

Use this function to retrieve a parameter or value from a string of characters. In other words, the function will scan the specified string of characters and retrieve a parameter according to the specified position. The function distinguishes parameters, and therefore their position, via the , separator.

For example:

GetParameter("11,22,33,44", 3)

In this case the function will return 33.

 

GetParameter("11,22,33,44", ??Q1??)

if Q1=1, the function will return 11.

 

It is possible to use a specific separator, For example:

GetParameter("11;22;33;44", 3, ";")

In this case the function will return 33.

InStr(,)

An abbreviation for InString.

Use this function to scan the response given to an open question, searching for a specific word or string of characters. If the specified string of characters is found, the function will return its position, from 1 onwards, and if not, the function will return 0.

For example:

InStr("CDE", ??Q1??)

if, during data collection Q1="ABCDEFGHIJKLMNOPQRSTUVWXYZ", the function returns the value 3.

Note: This function is not case sensitive. It will return only one value, regardless of whether or not the response contains the specified string of characters more than once.

IsDate

Use this function to verify that one or more responses conforms to the date format (dd/mm/yy or dd/mm/yyyy).

For example:

IsDate??Q1??

IsDate(??Day??+"/"+??Month??+"/"+??Year??)

IsEmail

Use this function to verify that a response conforms to a valid email address format, i.e. x@x.xxx

It checks for the following characters; if any are present, the function returns false: àâäãçéèêëìîòôöõùûüñ &*?!:;,t#~"^¨%$£?²¤§%()[]{}|/`' and space .. and ... and @@

For example:

IsEmail??Q1??

LCase()

Use this function to return the specified string converted to lowercase.

For example:

LCase("ABC") returns "abc"

Len()

Abbreviation for length.

Use this function to calculate the length of a string of characters and retrieve that length as a numerical value.

For example:

Len(??Q1??)

if Q1="ABCDEFGHIJKLMNOPQRSTUVWXYZ", the function will return: 26.

Note: The function includes spaces when measuring the length of a string of characters, so that if Q1="A B" the function would return 3.

Mid(?? ??, ,)

Use this function to extract a sub-string from a given position within the specified string.

The first parameter is the string from which you want to extract the sub-string. The second paraemter is the starting position of the sub-string The third is the length of the sub-string.

For example:

Mid(??Q1??, 5, 10)

if Q1="ABCDEFGHIJKLMNOPQRSTUVWXYZ", the function will return: EFGHIJKLMN (i.e. starting at position 5 in Q1, and comprising the next 10 characters).

ReadBinaryFile()

Use this function to return the contents of a binary file and transform it into hexadecimal so it can be stored in an open-ended question.

Note: This function is only available within AskiaDesign and AskiaEntry. The data collected can, however, be exported with askiatools.

ReadBinaryFile("D:Workspaceint1.txt")

ReadBinaryFile("D:Workspaceint" + ??Q1?? + ".txt")

ReadTextFile()

Use this function to return the content of a text file and it can be stored in an open-ended question.

Note: This function is only available within AskiaDesign and AskiaEntry.

ReadTextFile("D:Workspaceint1.txt")

ReadTextFile("D:Workspaceint" + ??Q1?? + ".txt")

Note: This function supports Unicode and UTF-8 encoded files.
Since 561: 

We have allowed the ReadTextFile which has been in AskiaScript for ever to read directly from the resources

So you can have something like this:

 


dim CeSettings as Dictionary
dim read_data=ReadTextFile("MyJsonFile.json")
CeSettings.LoadJSON(read_data)
json_settings_ce.setValue(CeSettings.ToString())
usewatermark_ce.SetValue(on(CeSettings["use_watermark"].ToBoolean(),{1},{2}))

 

And it will work in all modes (including AskiaTools).

Replace(,,)

Replace(String,Search,ReplaceBy)

Use this function to Replace the specified portion of a string with another string.

For example:

Replace("The cat is white","cat","dog") returns "The dog is white"

UCase()

Use this function to return the string converted to uppercase.

For example:

UCase("abc") returns "ABC"

Val()

Use this function to retrieve a numeric value which was originally entered as a string value, thereby enabling you to treat this value as if it came from a numeric question.

For example:

Val(??Q1??)

if Q1="123", the function will return the numeric value: 123.

 

Note: as it is not able to recognize numeric characters contained in an alphanumeric string, if Q1="text 123 text", the function will therefore return the value: 0.
Create your own Knowledge Base