From WikiChip
Editing mirc/aliases
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | {{ | + | {{mIRC Guide}} |
In many cases, it is easier to code a large program by working with a single, small, unit of logic at a time. Aliases, more commonly known in other languages as functions, are blocks of code which performs a specific task and can be relatively independent of the rest of the script. Most aliases are created to be used multiple times by different scripts. In addition to their normal usage, aliases can also be used to create custom [[#Shortcuts_and_Function_Keys|shortcuts and function keys operations]]. | In many cases, it is easier to code a large program by working with a single, small, unit of logic at a time. Aliases, more commonly known in other languages as functions, are blocks of code which performs a specific task and can be relatively independent of the rest of the script. Most aliases are created to be used multiple times by different scripts. In addition to their normal usage, aliases can also be used to create custom [[#Shortcuts_and_Function_Keys|shortcuts and function keys operations]]. | ||
Line 10: | Line 10: | ||
;multi-line alias | ;multi-line alias | ||
alias aliasName { | alias aliasName { | ||
− | + | ;commands | |
}</syntaxhighlight> | }</syntaxhighlight> | ||
Line 27: | Line 27: | ||
<pre>Hello World!</pre> | <pre>Hello World!</pre> | ||
− | + | == Alias arguments == | |
Data can be passed to aliases via the argument list. The argument list is always evaluated from left to right. The arguments are passed to the alias via the $N identifiers, where N is a numeric value from starting at one. | Data can be passed to aliases via the argument list. The argument list is always evaluated from left to right. The arguments are passed to the alias via the $N identifiers, where N is a numeric value from starting at one. | ||
Line 39: | Line 39: | ||
Alias example will have $1 returning 'A', $2 returning 'B', $3 returning 'C', and $4 returning 'D'. The total number of tokens available can be retrieved via the $0 identifiers. In this case $0 will return 4. | Alias example will have $1 returning 'A', $2 returning 'B', $3 returning 'C', and $4 returning 'D'. The total number of tokens available can be retrieved via the $0 identifiers. In this case $0 will return 4. | ||
− | The exact rules on how $N work is identical to the how they work with the [[Token Manipulation - mIRC#Tokenizing_a_string|/tokenize command]]. | + | The exact rules on how $N work is identical to the how they work with the [[Token Manipulation - mIRC#Tokenizing_a_string|/tokenize command]]. |
− | + | ||
− | + | == Aliases Tab == | |
The aliases tab is designed specifically for aliases only. Note that because it can only be used for aliases, the "alias" prefix must be left out: | The aliases tab is designed specifically for aliases only. Note that because it can only be used for aliases, the "alias" prefix must be left out: | ||
Line 51: | Line 51: | ||
'''Note:''' Aliases from the aliases tab can freely call aliases from the remote tab and vice versa. | '''Note:''' Aliases from the aliases tab can freely call aliases from the remote tab and vice versa. | ||
− | + | == Commands vs. Identifiers == | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | in mSL, aliases can serve as both '''identifiers''' and '''commands'''. These two terms are used to describe the type of alias it is. In general, a '''command''' will usually not return anything but simply process some type of data. An '''Identifier''' on the other hand will generally returns some kind of a value. | |
− | + | === Commands === | |
− | |||
− | === | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | = | ||
A command usually does not return any value, but instead, it processes the arguments it's given. In a command, every argument is separated by a space. $0 will contain the total number of arguments passed to that alias. $N (where N is a number 1 to $0) will contain the arguments. For example: | A command usually does not return any value, but instead, it processes the arguments it's given. In a command, every argument is separated by a space. $0 will contain the total number of arguments passed to that alias. $N (where N is a number 1 to $0) will contain the arguments. For example: | ||
Line 118: | Line 79: | ||
Arg3 = C</pre> | Arg3 = C</pre> | ||
− | == Identifiers == | + | === Identifiers === |
Generally, an identifier is a value-returning alias. This means we pass some arguments to that alias and we expect it to return something in return. Identifiers are prefixed with the dollar symbol ($). An identifier may or may not need arguments to be passed to it. If the identifier requires that some arguments be passed to it, the arguments must be in a parenthesis, comma delimited. | Generally, an identifier is a value-returning alias. This means we pass some arguments to that alias and we expect it to return something in return. Identifiers are prefixed with the dollar symbol ($). An identifier may or may not need arguments to be passed to it. If the identifier requires that some arguments be passed to it, the arguments must be in a parenthesis, comma delimited. | ||
Line 140: | Line 101: | ||
<pre>hello there!</pre> | <pre>hello there!</pre> | ||
− | + | === Identifiers Properties === | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | == Identifiers Properties == | ||
Properties are a unique feature to identifiers with arguments. They allow you to pass one more additional remark to the alias. That remark can be retrieved from within the alias using the '''$prop''' identifier. Properties are usually a way to manipulate the arguments we pass to the alias. | Properties are a unique feature to identifiers with arguments. They allow you to pass one more additional remark to the alias. That remark can be retrieved from within the alias using the '''$prop''' identifier. Properties are usually a way to manipulate the arguments we pass to the alias. | ||
Line 217: | Line 164: | ||
<pre>/logfind *kicked* | <pre>/logfind *kicked* | ||
* Logfind Match: [12:33] * Foo was kicked by *.example.com (Flooding (Limit is 12 lines per 10 seconds))</pre> | * Logfind Match: [12:33] * Foo was kicked by *.example.com (Flooding (Limit is 12 lines per 10 seconds))</pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Additional alias features: == | == Additional alias features: == | ||
− | Regardless of whether or not an alias was called as a command or as an identifier, if it used the /return command to return back, you can get that value using the '''$result''' identifier. | + | Regardless of whether or not an alias was called as a command or as an identifier, if it used the /return command to return back, you can get that value using the '''$result''' identifier. |
− | <syntaxhighlight lang="mIRC">alias example { | + | <syntaxhighlight lang="mIRC">alias example { |
foo | foo | ||
echo -a $result | echo -a $result | ||
Line 291: | Line 184: | ||
In addition, aliases can be coded to work in verbose mode or not. If the command was prefixed with the dot (.) symbol, $show will return $false, otherwise it will $true. For example: | In addition, aliases can be coded to work in verbose mode or not. If the command was prefixed with the dot (.) symbol, $show will return $false, otherwise it will $true. For example: | ||
− | <syntaxhighlight lang="mIRC">alias example { | + | <syntaxhighlight lang="mIRC">alias example { |
if ($show) { | if ($show) { | ||
;Indicate we are doing something | ;Indicate we are doing something | ||
Line 306: | Line 199: | ||
/.example</syntaxhighlight> | /.example</syntaxhighlight> | ||
− | '''Note:''' /echo -q is a built-in alternative to | + | '''Note:''' /echo -q is a built-in alternative to checking $show on your own. |
<h3 id="shortcuts">Shortcuts and Function Keys</h3> | <h3 id="shortcuts">Shortcuts and Function Keys</h3> | ||
− | Aliases can be used to redefine function keys and shortcuts by simply renaming them the actual key or key combinations. For the F-keys all you need is to name the actual alias F1 through F12. C | + | Aliases can be used to redefine function keys and shortcuts by simply renaming them the actual key or key combinations. For the F-keys all you need is to name the actual alias F1 through F12. C and S can be used for the Shift and Ctrl Key. For example SF1 is Shift+F1 keys. |
For Example: | For Example: | ||
− | < | + | <syntaxhighlight lang="mIRC">alias SF1 { |
echo -a Shift+F1 was pressed! | echo -a Shift+F1 was pressed! | ||
− | } | + | }</syntaxhighlight> |
− | |||
− | |||
− | |||
− | |||
− | </ | ||
== Local Aliases == | == Local Aliases == | ||
Line 342: | Line 230: | ||
}</syntaxhighlight> | }</syntaxhighlight> | ||
− | If some code local to that script file calls example, the local alias will execute. If some other code outside of this script file calls it the second alias will execute instead. | + | If some code local to that script file calls example, the local alias will execute. If some other code outside of this script file calls it the second alias will execute instead. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |