Introduction Updates Course Notes Course Test Examples |
Getting Started |
Aliases |
/msg and /echo |
Identifiers You'll find that if-then-else and goto commands are vital to a complex script, so you'll need a good grasp of how to use them. If you've done any programming before, you'll know basically what if-then-else statements do. In short, If something is true, Then a command will be evaluated, or Else another command will be executed. The Else is optional, and I rarely use it. It can be useful if you want the script respond to an input in different ways depending on what it is. For example, in my pinfinder script, if the pin is for a TC pin, then a different set of commands must be run than if it is a DB pin. The following is the syntax: If (v1 operator v2) [Then commands] Elseif is another optional part
of IF-THEN statements which I rarely use. Basically, the first IF
statement isn't true, so it checks a different statement, the ELSEIF.
You can have as many elseif's within a single if statement as you want.
/iftest { Ok, let's see what happens, type /iftest in a channel. You'll be asked to enter a number. Try 1. You'll see x equals 1. Try out 2. Now it says x equals 2. If you try 3 you'll see x is less than 5. The number 12 will yield x is greater than 10. While 7 will tell you x is not a very good number. Let's take a closer look at operators. Here are a couple of the most useful :
You may have seen some of these in math class before, and they are pretty self explanatory. The one you don't recognize is probably isin, which you've never seen in math class, unless you had a strange math class. Basically, it test to see if one string of characters is in another string of characters. So ("ell" isin "hello") would be true, but ("no" isin "hello") would not be true. There are in all about 30-40 different operators in mIRC, a complete list can be found in the mIRC help file (do a search for ==). {} Brackets can be used in if-then-else statements, so your commands after the if statement can go on as long as you want, let's take a look:
/ifstuff { (Note: Make sure that you close all {} Brackets you open in a script) Notice that I didn't use any elseif or else lines in this script, they are always optional. Run the script by typing /ifstuff. You'll see the following output if you enter the number 1:
This is line 1 Now run it again, but enter the number 2: this is not part of the if So all commands within the {} brackets of an if statement are considered part of it. If lines are a very important part of any complex script that responds to things entered. |