SetVar

Purpose:

Assign a value to a variable.

Category:

Variables

Syntax:

SetVar [variable] "value"

variable

Variable to store the value.

value

Value to be stored. Use quotes to store a string and do not use them to store a numeric value.

Example:

SetVar [greeting] "Hello!"
SetVar [age] 34



SetCompVar

Purpose:

Assign a value to a composed variable.
A composed variable is a variable whose name is composed of a fixed part and a mutable 

-index like- part. Its value can retrieved by the mutable part if it has a numeric value (i.e. 0, 1, 2, 3, …) or by the function GetCompVar.

Category:

Variables

Syntax:

SetCompVar [var1[var2]] "value"

var1

First fixed part of the composed variable.

var2

Second mutable part of the composed variable.

value

Value to be stored.

Example:

SetVar [index] 1

SetCompVar [greeting[index]] "Hey"

AlertBox "Variable value:" "[greeting1]" ""


The following gives an error:

AlertBox "Variable value:" "[greeting[index]]" ""


Solution: see the function GetCompVar.



GetCompVar

Purpose:

Get the value from a composed variable (see SetCompVar) and assign it to a regular one.

Category:

Variables

Syntax:

GetCompVar [result] [var1[var2]]

result

Variable to store the result.

var1

First fixed part of the composed variable.

var2

Second mutable part of the composed variable.

Example:

SetVar [index] 1

SetCompVar [myCar[index]] "Volvo"

GetCompVar [result] [myCar[index]]

AlertBox "Variable value:" "[result]" ""


SetVar [key] "Toyota"

SetCompVar [price[key]] "Euro 30.000"

GetCompVar [result] [price[key]]

AlertBox "Variable value:" [result] ""


SetVar [key] "Saab"

SetCompVar [price[key]] "Euro 50.000"

GetCompVar [result] [price[Saab]]

AlertBox "Variable value:" [result] ""



DeleteVar

Purpose:

Remove a variable from memory.

Category:

Variables

Syntax:

DeleteVar [variable]
variable

Variable to delete.

Example:

DeleteVar [myVar]


IsVarEmpty

Purpose:

Test variable to determine if it contains a value. Returns true or false.

Category:

Variables

Syntax:

IsVarEmpty [variable] [result]

variable

Variable to test.

result

Variable to store the result.

Example:

IsVarEmpty [myVar] [result]


TypeOf

Purpose:

Find the type of a JavaScript variable (string, number, boolean...)

Category:

Variables

Syntax:

TypeOf [variable] [result]
variable

Variable to get it's type.

result

Variable to store the result.

Example:

SetVar [myVar] "string"

TypeOf [myVar] [result]


SwapVars

Purpose:

Swap two variables values

Category:

Variables

Syntax:

SwapVars [variable1] [variable2]
variable1

First variable

variable2

Second variable.

Example:

SetVar [myVar1] "hello"

SetVar [myVar2] "bye"

SwapVars [myVar1] [myVar2]


--> As a result [myVar1] will store "bye" and [myVar2] "hello"


Watch

Purpose:

Monitor a variable and execute a subroutine whenever its content changes. Use CancelWatch to stop monitoring.

Category:

Variables

Syntax:

Watch [variable] "subroutine"

variable

Variable to wait for changes.

subroutine

Subroutine name to execute each time the variable's value has changed.

Example:

Watch [myVar] "mySubroutine"


CancelWatch

Purpose:

Stop monitoring a variable for changes.

Category:

Variables

Syntax:

CancelWatch [variable]

variable

Variable to stop wathing for changes.

Example:

CancelWatch [myVar]


TextToClipboard

Purpose:

Copy a text to the device clipboard.
IMPORTANT: For security reasons it will work only after a user action ie: clicking a button.

Category:

Variables

Syntax:

TextToClipboard "text"

text

Text to copy to the Clipboard

Example:

TextToClipboard "Hello clipboard!"


ClipboardToVar

Purpose:

Copy the device Clipboard content into a variable.
IMPORTANT: Only available in compatible web browsers. Requieres user permission.

Category:

Variables

Syntax:

ClipboardToVar [varable]

variable

Variable to store the clipboard content

Example:

ClipboardToVar [myVar]


CreateArray

Purpose:

Create a new array variable using the supplied content. Separate array elements with line breaks if you are using the wizard window or commas if you are writing the code directly.
Use this command entering data manually. Do not use a variable to fill the data.

Category:

Variables

Syntax:

CreateArray [arrayVariable] "value1,value2,value3"

arrayVariable

Variable array name to store the values.

value1,value2,value3...

Items to store in the array, separated by comma and enclosed by double apostrophes in case of strings.

Example:

CreateArray [myArray] "red,blue,orange,brown,white"

CreateArray [myArray] 1, 2, 3


Tip 
Study the section about Variable Arrays (Understanding Actions and Variables)!


CreateEmptyArray

Purpose:

Create an empty array variable.

Category:

Variables

Syntax:

CreateEmptyArray [arrayVariable]

arrayVariable

Variable array name.

Example:

CreateEmptyArray [myArray]
SetVar [myArray(0)] "a, z"
SetVar [myArray(1)] "b"
SetVar [myArray(2)] "c"


AlertBox "" "[mcArray(0)]" ""


-> expected value: a, z


ArrayLen

Purpose:

Calculate the number of items in an array.

Category:

Variables

Syntax:

ArrayLen [arrayVariable] [result]

arrayVariable

Variable array name.

result

Variable to store the number of items.

Example:

CreateEmptyArray [myArray]
SetVar [myArray(0)] "a, z"
SetVar [myArray(1)] "b"
SetVar [myArray(2)] "c"


ArrayLen [myArray] [numberOfItems]


-> [numberOfItems] has the value 3 (!)


ArrayAddItem

Purpose:

Add a new item to the end of an array.

Category:

Variables

Syntax:

ArrayAddItem [arrayVariable] "item"

arrayVariable

Variable array name.

item

String to add to the array (or number without quotes).

Example:

CreateArray [myArray] "red,blue,orange,brown,white"

ArrayAddItem [myArray] "yellow"


-> [myArray] has the value "red,blue,orange,brown,white,yellow"


Remark

To add a new item to the beginning of an arry, use ArrayCombine. 

Example:        CreateArray [myArray1] "red,blue,orange,brown,white"

SetVar [myArray2] "yellow,"

ArrayCombine [myArray2] [myArray1] [myArray]


-> [myArray] has the value "yellow,red,blue,orange,brown,white"


               

ArrayDelItem

Purpose:

Remove an item from an array. Notice that arrays are zero based.

Category:

Variables

Syntax:

ArrayDelItem [arrayVariable] index

arrayVariable

Variable array name.

index

Item number to delete.

Example:

CreateArray [myArray] "red,blue,orange,brown,white"

ArrayDelItem [myArray] 3


-> the item "brown" is now removed from [myArray]


ArrayAlphaSort

Purpose:

Sort an array alphabetically.

Category:

Variables

Syntax:

ArrayAlphaSort [arrayVariable]

arrayVariable

Variable array name.

Example:

CreateArray [myArray] "b, 2, b, a, 1"

ArrayAlphaSort [myArray]


-> [myArray] has now the value "1, 2, a, b, b"


ArrayNumSort

Purpose:

Sort an array numerically.

Category:

Variables

Syntax:

ArrayNumSort [arrayVariable]

arrayVariable

Variable array name.

Example:

ArrayNumSort [myArray]



ArrayReverse

Purpose:

Reverse the order of items in an array.

Category:

Variables

Syntax:

ArrayReverse [arrayVariable]

array name

Variable array name.

Example:

CreateArray [myArray] "begin,a,b,end"

ArrayReverse [myArray]


-> [myArray] has now the value "end,b,a,begin"


ArrayShuffle

Purpose:

Randomize (shuffle) an array.

Category:

Variables

Syntax:

ArrayShuffle [array1] [array2]

array1

Array to suffle.

array2

Destination array.

Example:

ArrayShuffle [myArray] [myRandomizedArray]



ArrayCombine

Purpose:

Combine the contents of two arrays into a single new array.

Category:

Variables

Syntax:

ArrayCombine [array1] [array2] [newArray]

array1

First array name.

array2

Second array name.

newArray

New array name to combine the previous two arrays.

Example:

ArrayCombine [myArray1] [myArray2] [myCombinedArray]


ArrayCopy

Purpose:

Create a new array using a portion of an existing array.

Category:

Variables

Syntax:

ArrayCopy [arrayVariable] index numberOfItems [newArray]

arrayVariable

Variable array name.

index

Index of first array item.

numberOfItems

Number of items to copy.

newArray

New array name to copy the selected items.

Example:

CreateArray [myArray] "red,blue,orange,brown,white"

ArrayCopy [myArray] 1 2 [newArray]


-> [newArray] has now the value "blue,orange"


ArraySearch

Purpose:

Find the first matching item in an array. Returns the index number, starting by zero, of the found item or -1 if no match is found.

Category:

Variables

Syntax:

ArraySearch [arrayVariable] "value" [result]

arrayVariable

Variable array name.

value

Item to find.

result

Variable to store result.

Example:

CreateArray [myArray] "red,blue,orange,brown,white"

ArraySearch [myArray] "blue" [colorPosition]


-> [colorPosition] has the value 1