Engine:CCMD var: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{\|dev|macronav}} Creates a new variable int eh current context, if doesn't exist. var bob fred == Arguments == * name - name for new variable * value - the value to set == Notes == *") |
No edit summary |
||
(13 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ | {{dev/uiccmd}} | ||
Creates a new variable | Creates a new variable in the current context, if doesn't exist. If exists is ignored. | ||
<kua>var bob fred</kua> | |||
== Arguments == | == Arguments == | ||
* name - name for new variable | * name - name for new variable | ||
* value - the value to set | * value (optional) - the value to set. If no value, then prints value if exists. | ||
== Details == | |||
Can be used to set defaults for values. | |||
== Examples == | |||
=== Default values === | |||
* 'var' called with 'bob' without a value. Variable 'bob' doesn't exist. | |||
<kua> | |||
> var bob | |||
Unknown: bob | |||
</kua> | |||
* Creates variable 'bob' and sets to 'fred'. | |||
<kua> | |||
> var bob fred | |||
</kua> | |||
* Same as the first example, but now bob exists. | |||
<kua> | |||
> var bob | |||
'bob' is 'fred' | |||
</kua> | |||
* Try to set 'bob' to 'james', but 'bob' is already set. | |||
<kua> | |||
> var bob james | |||
> var bob | |||
'bob' is 'fred' | |||
</kua> | |||
== Notes == | == Notes == | ||
* | * If variable already exists, will not trigger any associated events when attempting to set. |
Latest revision as of 21:37, 16 October 2023
Creates a new variable in the current context, if doesn't exist. If exists is ignored.
var bob fred
Arguments[edit]
- name - name for new variable
- value (optional) - the value to set. If no value, then prints value if exists.
Details[edit]
Can be used to set defaults for values.
Examples[edit]
Default values[edit]
- 'var' called with 'bob' without a value. Variable 'bob' doesn't exist.
> var bob Unknown: bob
- Creates variable 'bob' and sets to 'fred'.
> var bob fred
- Same as the first example, but now bob exists.
> var bob
'bob' is 'fred'
- Try to set 'bob' to 'james', but 'bob' is already set.
> var bob james
> var bob
'bob' is 'fred'
Notes[edit]
- If variable already exists, will not trigger any associated events when attempting to set.