Scripts can "create" up to 200 user-defined local variables per script. The userset command is used to create and/or set local user variables. Local variables only remained defined within the script they were created in. They are not accessible from sub-scripts. Note that you can pass the value of a local variable to a sub-script by specifying it as a parameter. Once a local variable has been created, it can be accessed and changed like any other variable type.
localset NEXTOBJECT ; this creates NEXTOBJECT and clears its contents
localset NEXTOBJECT M31 ; this sets its value
set NEXTOBJECT M31 ; this works because it was already created with 'localset'
NEXTOBJECT= M31 ; this also works because it was already created with 'localset'
echo "The next object is" $NEXTOBJECT ; this displays "The next object is M31" to the screen and log files
Local variable names:
- can contain any reasonable combination of numbers, letters, and symbols provided they don't have special meaning (such as ":", "=", ";", etc.).
- can conflict with other variables such as the pre-defined variables or global variables. In the case of a conflict the local variable takes precedence.
- are not case-sensitive, but it is good convention to use all CAPITAL LETTERS so as to make them easily identifiable.