VARIABLE
Syntax: #VA varname value defaultval classname
Similar to the #ALIAS command. Assigns the specified value to the varname variable. You should leave off the @ variable character. This allows you to define variables independent of the user's variable character setting.
An alternative syntax is
variable = value
or
variable := value
If a defaultval is specified, the variable is initialized to that value when the settings are loaded or the #RESET command is used. To specify no default, leave this parameter out or use the _nodef value.
When used without any parameters all variables are displayed. If variable is the only parameter then just its value is displayed.
Normally, variables are "auto-typed". This means that CMUD automatically converts the variable contents to numbers or strings as needed by your script. The "type" of a variable can be explicitly changed in the Pakage Editor, or by using the %vartype function.
This command can also be used to set the value of local variables. The $ local variable character must be used to set the value of a local variable. You should be careful when using local variable names and #var to avoid problems.
VARIABLE examples
#VA coins 1000
assign 1000 to the @coins variable
coins = 1000
same as above.
#VA people john mary joseph
This creates the variable @people in the class joseph with a value of john and a default of mary. To have the value be john mary joseph use braces to separate the parameters: #VA people {john mary joseph}
#VA simple abc
#VA @simple def
This one creates the variable @simple with a value of abc. Then creates the variable @abc with a value of def. You should never have an @ in the variable name unless you plan to create an indirect reference such as this.
$name=Zugg;#VA $name cool
Sets the value of the $name local variable to "Zugg" and then changes its value to "cool".
$name=Zugg;#VA %eval($name) cool
Sets the value of the $name local variable to "Zugg" and then sets the value of the global variable @Zugg to "cool". |