Engine:CCMD alias: Difference between revisions

 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{dev/uiccmd}}
{{dev/uiccmd}}
Creates a new alias wiht a callable script in the current context, replacing existing alias if any.
Creates a new alias with a callable script in the current context, replacing existing alias if any.
<kua>alias bob "echo fred"</kua>
<kua>alias bob "echo fred"</kua>


== Arguments ==
== Arguments ==
* name - name for the new alias
* name - name for the new alias
* value - script string or command to set as an alias
* value (optional) - script string or command to set as an alias. If not supplied, then prints the alias script value if the alias exists.


== Associations ==
== Associations ==
Line 15: Line 15:
Aliases do not have any parameters and will run the command, statement, or script verbatim. If for example, an alias named 'bob' is set to 'echo', it will always run exactly 'echo' which will print nothing, even if you run 'bob "some text". Here the second parameter was ignored.
Aliases do not have any parameters and will run the command, statement, or script verbatim. If for example, an alias named 'bob' is set to 'echo', it will always run exactly 'echo' which will print nothing, even if you run 'bob "some text". Here the second parameter was ignored.


Thus, aliases act like simple static macros. But when run they can do anything a script in the same context run by any other means could do. And because aliases are treated like commands, they can have direct key bindings.
Thus, aliases act like simple static macros. But when run they can do anything a script in the same context run by any other means could do. And because aliases are treated like commands, they can use the special key state associations. By default, only aliases in the 'global' context will be found by key bindings using 'bind'.


== Examples ==
== Examples ==
=== Default values ===
=== Default values ===
* Checks alias 'bob' for script value. No alias exists named 'bob'.
* Check alias 'bob' for script value. No alias exists named 'bob'.
<kua>
<kua>
> alias bob
> alias bob
Unknown: bob
Unknown: bob
</kua>
</kua>
* 'bob' called without a value. No command, variable or alias named 'bob' exist.
* Call 'bob'. No command, variable or alias named 'bob' exist.
<kua>
<kua>
> bob
> bob