From WikiChip
Editing mirc/introduction
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: | ||
− | {{ | + | {{Template:mIRC Guide}} |
+ | {{DISPLAYTITLE:Introduction - mIRC}} | ||
This article focuses on the very basics of mIRC Scripting. The target audience is people with no knowledge, or very limited knowledge, of the [[mirc|mIRC scripting language]]. | This article focuses on the very basics of mIRC Scripting. The target audience is people with no knowledge, or very limited knowledge, of the [[mirc|mIRC scripting language]]. | ||
Line 29: | Line 30: | ||
statement 3 | statement 3 | ||
statement 4</pre> | statement 4</pre> | ||
− | |||
− | |||
=== What's with the slashes? === | === What's with the slashes? === | ||
Line 42: | Line 41: | ||
=== /echo command === | === /echo command === | ||
− | The most common type of statements are {{mirc|commands}}. Commands are a way to tell mIRC to perform a basic operation. By far the most common command you will be using is the {{mirc|/echo}} command. The /echo command simply prints text to the screen. Every echo command prints on a line of its own | + | The most common type of statements are {{mirc|commands}}. Commands are a way to tell mIRC to perform a basic operation. By far the most common command you will be using is the {{mirc|/echo}} command. The /echo command simply prints text to the screen. Every echo command prints on a line of its own. |
Let's dive right into an example! Type the following code into your editbox: | Let's dive right into an example! Type the following code into your editbox: | ||
Line 52: | Line 51: | ||
<pre>Hello World!</pre> | <pre>Hello World!</pre> | ||
[[File:Hello edit.png]] | [[File:Hello edit.png]] | ||
− | |||
− | |||
Recall we said earlier that multiple statements can be combined by using the pipe '|'? Let's print 3 lines to the screen using the echo command and some pipes. Type the following code into your editbox (''Remember to hit the Return or Enter keys from now on''): | Recall we said earlier that multiple statements can be combined by using the pipe '|'? Let's print 3 lines to the screen using the echo command and some pipes. Type the following code into your editbox (''Remember to hit the Return or Enter keys from now on''): | ||
Line 68: | Line 65: | ||
'''Note''': As you may have noticed, from the editbox, you can only pipe statements, you can't use newlines. | '''Note''': As you may have noticed, from the editbox, you can only pipe statements, you can't use newlines. | ||
− | You will notice that after the first ''//echo'' command, once we've piped, we do not need to type | + | You will notice that after the first ''//echo'' command, once we've piped, we do not need to type anymore slashes; this is because mIRC interprets the rest of the statements via the first initial slashes. |
− | If you use one slash here, "Scripting | echo Is | echo Fun!" will be echoed, because the pipes have not been interpreted | + | If you use one slash here, "Scripting | echo Is | echo Fun!" will be echoed, because the pipes have not been interpreted. We usually refer to this as 'evaluation', we will discuss it later. |
− | |||
− | |||
− | |||
− | |||
=== Let's make it into an alias, shall we? === | === Let's make it into an alias, shall we? === | ||
Line 95: | Line 88: | ||
# The two // were removed; we only really need one or two forward-slashes when we want to execute code directly from the editbox. Using slashes in your script editor adds nothing but clutter. | # The two // were removed; we only really need one or two forward-slashes when we want to execute code directly from the editbox. Using slashes in your script editor adds nothing but clutter. | ||
− | |||
# Because we used the '''alias''' keyword, the code must go in the '''Remote Tab''' of the script editor. In order to use that code from the aliases tab, you must remove the "alias" keyword. The rest of the code stays the same. | # Because we used the '''alias''' keyword, the code must go in the '''Remote Tab''' of the script editor. In order to use that code from the aliases tab, you must remove the "alias" keyword. The rest of the code stays the same. | ||
Line 109: | Line 101: | ||
<pre>/fun</pre> | <pre>/fun</pre> | ||
− | '''Note:''' Two forward-slashes will also call it | + | '''Note:''' Two forward-slashes will also call it, but for now, let's only use a single forward-slash |
That should print our text again: | That should print our text again: | ||
Line 128: | Line 120: | ||
''But we have just seen three statements with piping; we didn't need to use a pair of brackets there?'' | ''But we have just seen three statements with piping; we didn't need to use a pair of brackets there?'' | ||
− | + | Yes! We don't need the brackets because they are only there to help distinguish between two or more blocks of code. In some situations, the distinction can be made without them: | |
− | + | <source lang="mIRC">alias fun echo Scripting | echo Is | echo Fun!</source> | |
+ | All ''/echo'' commands are on the same 'level'. This simply means that you want all of them to execute, no matter what, as quickly as mIRC can parse them. Some statements, such as the {{mirc|conditional statements}}, allow you to create others blocks of code. Within those new blocks of code, you must use brackets. However, if the context allows it, you can get around using them; the example below illustrates this scenario: | ||
− | |||
− | |||
− | |||
− | |||
− | |||
<source lang="mIRC">alias fun if (1 == 1) echo Scripting | if (2 == 3) echo Is | echo = | echo Fun!</source> | <source lang="mIRC">alias fun if (1 == 1) echo Scripting | if (2 == 3) echo Is | echo = | echo Fun!</source> | ||
− | In the example above, the statement ''echo Scripting'' belongs to the ''if (1 == 1)'' statement. The same is true for ''echo Is'', which, however, will not be echoed because the condition is not true. ''echo ='' '''does not''' belong to the ''if (2 == 3)'' statement like ''echo Is'' does; the reason being | + | In the example above, the statement ''echo Scripting'' belongs to the ''if (1 == 1)'' statement. The same is true for ''echo Is'', which, however, will not be echoed because the condition is not true. ''echo ='' '''does not''' belong to the ''if (2 == 3)'' statement like ''echo Is'' does; the reason being because we did not use a pair of brackets. Overall, the above example will echo: <pre>Scripting = Fun!</pre>. This is equivalent to: |
<source lang="mIRC">alias fun { if (1 == 1) { echo Scripting } | if (2 == 3) { echo Is } | echo = | echo Fun! }</source> | <source lang="mIRC">alias fun { if (1 == 1) { echo Scripting } | if (2 == 3) { echo Is } | echo = | echo Fun! }</source> | ||
− | + | This should help you understand how brackets are used. Here is a final example: | |
− | This should help you understand how brackets are used. | ||
<source lang="mIRC">alias fun { | <source lang="mIRC">alias fun { | ||
Line 158: | Line 145: | ||
# <span style="color: #DB0000;">The closing bracket '''must not''' touch anything else</span> | # <span style="color: #DB0000;">The closing bracket '''must not''' touch anything else</span> | ||
# <span style="color: #DB0000;">The closing bracket '''must''' be the last part of the block of code</span> | # <span style="color: #DB0000;">The closing bracket '''must''' be the last part of the block of code</span> | ||
− | |||
− | |||
=== <span style="color: #256B22;">Right Examples</span> === | === <span style="color: #256B22;">Right Examples</span> === | ||
Line 201: | Line 186: | ||
== Comments == | == Comments == | ||
Comments are normal, readable text that can be placed inside of your script, and they are a good practice to help better explain to other scripters what's going on in your code. Technically speaking, a comment can say whatever you want it to say, and they are ignored when the program is executed, meaning they have no effect on the actual behavior of the code. | Comments are normal, readable text that can be placed inside of your script, and they are a good practice to help better explain to other scripters what's going on in your code. Technically speaking, a comment can say whatever you want it to say, and they are ignored when the program is executed, meaning they have no effect on the actual behavior of the code. | ||
+ | |||
+ | All comments are preceded by the ''';''' character, which is the semi-colon. | ||
=== Single-line Comments === | === Single-line Comments === | ||
Line 226: | Line 213: | ||
The second type of comment is the multi-line comment. A multi-line comment can, as its name suggests, span multiple lines. Multi-line comments are enclosed between the '''/*''' & '''*/''' characters. The syntax for a multi-line comment is: | The second type of comment is the multi-line comment. A multi-line comment can, as its name suggests, span multiple lines. Multi-line comments are enclosed between the '''/*''' & '''*/''' characters. The syntax for a multi-line comment is: | ||
− | <source lang="mIRC"> | + | <source lang="mIRC">/* This is |
− | |||
− | /* This is | ||
a multi-line | a multi-line | ||
comment! | comment! | ||
Line 286: | Line 271: | ||
The */ is not on a line of Its own. | The */ is not on a line of Its own. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Identifiers == | == Identifiers == | ||
Line 357: | Line 314: | ||
The ''//'' indicates the the line should be evaluated. ''$me'' is replaced with the corresponding value twice because the spaced out pipe '|' is interpreted as the delimiter of commands. | The ''//'' indicates the the line should be evaluated. ''$me'' is replaced with the corresponding value twice because the spaced out pipe '|' is interpreted as the delimiter of commands. | ||
<source lang="mIRC">/echo -a $me | echo -a $me</source> | <source lang="mIRC">/echo -a $me | echo -a $me</source> | ||
− | The ''/'' indicates that the line should not be evaluated. | + | The ''/'' indicates that the line should not be evaluated. $me is returned literally, and therefore is not replaced. The pipe is also not interpreted. |
{{mIRC|variables}} are also special, in that they need to be evaluated the same way as identifiers. Evaluating variables is the only way to extract the value that they hold. | {{mIRC|variables}} are also special, in that they need to be evaluated the same way as identifiers. Evaluating variables is the only way to extract the value that they hold. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== On your own: == | == On your own: == | ||
Line 399: | Line 338: | ||
<span style="color: #009300;">This</span> <span style="color: #FF0000;">is</span> <span style="color: #9C009C;">a</span> <span style="color: #009393;">cool</span> <span style="color: #D2D2D2;">example</span><span style="color: #009300;">.</span> | <span style="color: #009300;">This</span> <span style="color: #FF0000;">is</span> <span style="color: #9C009C;">a</span> <span style="color: #009393;">cool</span> <span style="color: #D2D2D2;">example</span><span style="color: #009300;">.</span> | ||
− | <source lang="mIRC">//echo -a The number | + | <source lang="mIRC">//echo -a The number �42� is even.</source> |
− | |||
− | |||
Will produce the following result: | Will produce the following result: | ||
Line 407: | Line 344: | ||
The number is even. | The number is even. | ||
− | Notice that the number is not showing. That's because it was considered part of the color number '42' | + | Notice that the number is not showing. That's because it was considered part of the color number '42'. Prefixing the color value with a zero will fix this issue: |
<source lang="mIRC">//echo -a The number �042� is even.</source> | <source lang="mIRC">//echo -a The number �042� is even.</source> | ||
Line 414: | Line 351: | ||
The number <span style="color: #FF0000;">2</span> is even. | The number <span style="color: #FF0000;">2</span> is even. | ||
− | |||
− | |||
=== Actions === | === Actions === | ||
Line 451: | Line 386: | ||
Next up are the {{mirc|aliases}}. If you feel comfortable with aliases, feel free to move on to {{mirc|variables}}. | Next up are the {{mirc|aliases}}. If you feel comfortable with aliases, feel free to move on to {{mirc|variables}}. | ||
− | [[Category:mIRC | + | [[Category:mIRC]] |