User Tools

Site Tools


docu_getvar

Get the value of a variable

By default the GETVAR function will look for variables stored in a generic_label device called “_VARSTORE_”. This default can be overridden by providing a different generic_label device as second function argument. If you want to use the default, simply create a generic_label device in your config with exactly this name: “_VARSTORE_”

Variables can be defined using the set action.

If the given variable name is found, its value is returned by the function. If the variable cannot be found, the function by default returns “*undefined*”.

Using a dedicated variable named “$default” this default can be overridden. Although the $default variable can be set with the set function like any other variable, the easiest way to do that is by manually adding this variable at the beginning of the label being used by GETVAR, like this:

If the label is still empty: $default=your_default

If the label already contains variables: $default=your_default&. Note the & (ampersand) at the end. This is important!

Examples

IF GETVAR(myvar) == foobar THEN .... (searches for variable myvar in default "_VARSTORE_" device)

IF GETVAR(myvar, mylabel) == foobar THEN ... (searches for variable myvar in device "mylabel")
docu_getvar.txt · Last modified: 2018/08/06 20:25 by Niek