set
Module(s): vncanvas-base, vncanvas-vars
Description: Sets a user variable.
set, {param} |
Sets a user variable as specified. Parameters are given as {param:value, param:value, ...} |
| Parameter | Attributes and Description |
|---|---|
|
name:value
|
Can be multiple
name is the user variable id.
Supports booloean and arithmetic operations.value can be number, boolean (true/false), string or variable_id to set the given variable. Accepts array (e.g. [1,2,3]) as user variable value. If value is null, variable is deleted. If name is prefixed with '$', the variable becomes persistent, i.e. it retains its value and is not overwritten on a checkpoint load. Once set as persistent, the '$' prefix becomes optional when accessing the variable. Also, persistency can not be unset, but the variable can still be nulled and deleted. If value contains the keyword "random", a non-integer random number between the supplied minimum and maximum value is generated. (see sample below) |
The following user variables are set as given.
chapter = [
...
/* Three variables named var1, var2 and var3 are set simultaneously
to a boolean, number and string values respectively.
*/
set, {var1:true, var2:1, var3:"hello world"},
...
/* var4 is set to var2 value. Note the double-quotes in var2 name. */
set, {var4:"var2"},
...
/* adds 10 to var4 value */
/* note valid operators are +, -, *, /, % and !
so regular string vars should not contain these */
set, {var4:"+10"},
set, {var1:"!"}, /* toggles var1 to false */
...
/* Set var5 as a 4-element array */
set, {var5:[1,2,true,"string"]},
/* append to array, var5 now has 5 elements */
set, {var5:"new value"},
...
/* Set a persistent variable */
set, {$var6:false},
jump, {var6:true, label:"label1"},
/* jump is not executed because var6 is false */
...
/* Set a random value between 0 and 100 */
set, {var7:"random 0 100"},
/* if min & max is not given, value is between 0 and 1 */
set, {var7:"random"},
...
];