Engine:CCMD varedit: Difference between revisions

 
(10 intermediate revisions by the same user not shown)
Line 2: Line 2:
Sets an existing variable in the current context, reports variable value.
Sets an existing variable in the current context, reports variable value.
<kua>bob fred</kua>
<kua>bob fred</kua>
== Arguments ==
* name - name for variable to set
* value (optional) - the value to set. If no value, then prints value if exists.


== Associations ==
== Associations ==
* Is the default command for the 'global' context.
* Is the default command for the 'global' context.
* Does not have its own command name in 'global'.
* Does not have its own command name in 'global'.
== Arguments ==
* name - name for variable to set
* value (optional) - the value to set. If no value, then prints value if exists.


== Details ==
== Details ==
Can be used to set or report a value for an existing variable. Will fail if variable does not already exist.
Can be used to set or report a value for an existing variable. Will fail if variable does not already exist. In 'global' context, 'name' and 'value' are used directly in a statement with no command name.  


Behaves like a combination of 'var' and 'set', but will never create a variable:
Behaves like a combination of 'var' and 'set', but will never create a variable:
Line 21: Line 21:
== Examples ==
== Examples ==
=== Default values ===
=== Default values ===
* 'bob' without a value. Variable 'bob' doesn't exist, and 'bob' is not the name of anything else.
<kua>
<kua>
> bob
> bob
Unknown: bob
Unknown: bob
</kua>
</kua>
* Tries to set variable 'bob' to 'fred'. Fails as 'bob' does not exist.  
No 'bob' in the context. Variable 'bob' doesn't exist, and 'bob' is not the name of anything else.
 
<kua>
<kua>
> bob fred
> bob fred
Unknown: bob
Unknown: bob
</kua>
</kua>
* Using the 'set' command to create the variable 'bob' and set to 'fred'.  
Tries to set variable 'bob' to 'fred'. Fails as 'bob' does not exist.
 
<kua>
<kua>
> set bob fred
> set bob fred
</kua>
</kua>
* Same as the first example, but now 'bob' exists.
Uses the 'set' command to create the variable 'bob' and set value to 'fred'.
 
<kua>
<kua>
> bob
> bob
'bob' is 'fred'
'bob' is 'fred'
</kua>
</kua>
* Try to set existing 'bob' to 'james', value changes.  
Same as the first example, but now 'bob' exists.
 
<kua>
<kua>
> bob james
> bob james
Line 46: Line 49:
'bob' is 'james'
'bob' is 'james'
</kua>
</kua>
Tries to set existing 'bob' to 'james', value changes.


=== Change if exists ===
=== Change if exists ===
Line 96: Line 100:


== Notes ==
== Notes ==
* This is a 'default' command for the global context and is used by simply using the 'name' and 'value' directly in a statement. It does not have a name in global to call it by name.
* While 'varedit' is intended make console variable checking and editing easy, in combination with the other variable commands, can allow scripts and other types of macros to avoid lots of situations where complex logic would otherwise be required.
* This default command 'varedit' would allow writing a script that was intended to only set certain variables if another service or module had already created them.