IONIX ASL Variable Context

Variables in ASL can be declared in a number of ways, and with a number of different "contexts" (meaning: the parts of a script that the variable is visible to).

Server-Global Variables

Variables declared with the "global" keyword before any rules are global to the server in which the adapter runs. Hence multiple scripts can access the same variables. Server-global variables can take any data type including scalars, lists and tables. Server-global variables can only be shared by drivers running in the same server process. If you need to work with variables in another server's address space - you need to use script-global variables and setVariable/getVariable operations of the driver.

Script-Global Variables

Variables not marked as "global" or "local" are global to the script itself and can [often] be accessed using the setVariable and getVariable methods of the driver class (getVariable is not available for all driver types).

Note that the setVariable and getVariable operations of the driver can only handle scalar string values. So passing a list or table this way doesn’t work. Also: booleans and numbers get converted to strings as they are passed from script to script. Use server-global variables instead if you need to.

Default Variables

Not really a new type of context = the "default" keyword is equivalent to giving a variable a value if it hasn’t already got one. Variables like this are commonly script-global and can therefore be set using setVariable.

Rule-Local Variables

Variables declared as "local" at the TOP of the pattern of a rule are localized to the rule. This seems to involve pushing a copy of the current value (if there is one) and un-defining the variable. Changes made by the rule or rules it calls are cancelled when the rule itself exits. This is not true "local" since..

A) The value is available to child rules, which can change it.

B) The "push and restore" doesn’t happen if the variable didn’t already have a value (this can result in some unexpected things).

Scroll to Top