Site hosted by Angelfire.com: Build your free website today!
 
























 
Ronaldsoft:>mIRC Information:>Introduction to mIRC Scripting


Overview


These tutorials will focus on teaching newbies a few things about mIRC scripting. This section will be dealing with users being able to get the feel for the mIRC editting and understand the language a bit. The language that mIRC uses is not so difficult. There is basic common sense used in understanding lots of the key things. For example: By the end of this tutorial, or maybe even further, you should understand what is Key and what is Play, or in other words what is important and what is just added fun. I know that I said the Aliases were going to be the next thing covered, but you can't go further until you understand what is included with this section. Please read it if you want to understand a lot of things for mIRC. For this purpose, I will not be revealing the name of the next section from now on :-)


Language


For a lot of people, the most difficult part of understanding a new language for programming, or in our case mIRC Scripting, is figuring out what is really Key and what is Play. Think of it this way: You look at a computer and you see letters and things pasted onto the computers outside shell, or case. You might see a logo like Gateway or Packard-Bell printed on this case. Now, these logos are not needed in order for the computer to run, they were just added so that the company could have their mark on their products, and possibly for publicity. Another great way to look at this is if you take a look at a hamburger: It mainly needs 2 slices of bun (one for top and one for bottom) and a patty of meet cooked. Now, if you go to restaraunts, people add Ketchup (or Catsup), onions, pickles, peppers, Mustard, and the list goes on. The only thing needed are the buns and the burger patty; but, people add everything else to make their product just a little better than others. This is much like the case with understanding mIRC's scripting language (or any language, at that). You don't need a lot of things to make something work, but, adding lots of nice features makes your final project just that much better than most.


Language: The Order of Operations


Now, let's take a look at something very basic in mIRC: The Order of Operations. If you're in high school, this might sound familiar; it's used in Algebra a lot. Don't let this math scare you; some people are intimidated by it, but don't be; you'll be fine, trust me. The order of operations helps you understand when and how something should be done. Look at a real life situation for an example. Let's say, you're going to eat, and you need a plate to eat off of. After you're through eating, you're going to clean the plate and put it away. Just to give you an example, let's say you want to eat a sandwhich; here is a basic break-down of the tasks involved in completing this:

Get the ham (or veggy of your choice) sandwhich made
Get a plate
Put the sandwhich on the plate
Put cheese on the ham sandwhich
Eat the sandwhich
Wash the plate
Put the plate away

Now, you need good common sense, not great just good, in order to complete a lot of the scripting operations needed. You wouldn't start off by eating the sandwhich first, because there isn't a sandwhich yet; you haven't made it. Neither would you start by putting the plate away, because number one, you haven't gotten one out and number two without a plate, you'd have to eat without a plate at all. Basically, the order in which I have already listed, is most-likely the correct order. You'll notice that I put Put cheese on the ham/veggy sandwhich in there. This is to give you an idea of the Key and Play factor. You don't really need cheese, it just makes the sandwhich better. You really don't need a slice of ham/veggy, maybe just two slices of bread/VeggyBread; but what kind of sandwhich would that be? This is another mock-question that will come up when you script. You'll ask yourself "Well, I saw this awesome and it had a feature I liked, but not many features that I would like were in it. How can I make one that is as good and even BETTER?". Questions are never bad; as many questions as you can think are helpful in scripting. Ideas are wonderful as well; never limit your ideas to something. If you limit yourself, you won't go very far. You want to expand yourself and not let ANYTHING stop you.


Language: Understanding The Order of Operations


Let's try to understand the order of operations by taking a look at a simple command, that is most often used in mIRC: /join #Channel. This command is a very basic command in mIRC, and it's great for learning the order of operations. Now, the command here, /join, tells mIRC that we want to join a channel, which in this case is called #Channel. mIRC sees the /join command and waits for the next instruction for it to follow. It reads that you typed #Channel as the channel that you wish to join. mIRC then joins that channel for you. Okay, let's take it apart:

You wouldn't want to do this command: #Channel /join. It's common sense here, just like the sandwhich. You don't tell mIRC the channel name and then say that you want to join a channel. You want to let it know that you are going to /join a channel and then tell it the channel that you want to join. This is the case with a lot of mIRC's other functions, such as: $nick(#,N), $chan(N), etc. These functions all gather information about certain things in mIRC and on IRC. I will explain those commands later, so do not begin to get frustrated.


Language: The '$' character


In mIRC Scripting, $ will come in handy over and over again. It's a VERY widely used character and is Key in lots of places. You may have seen it if you have ever opened up the mIRC Editor and taken a look around. The $ is an identifier. Identifiers are used all over mIRC. Since the new mIRC, they are used a lot for mIRC's dialogs. The $ is a special character in mIRC. In most cases where you see it, it was Key to doing certain things. Understand that knowing this is very important in understanding how to script in mIRC. The importance of this is very high in order for you to understand how to understand the scripting and the techniques used by anyone in any addon or script. There is no real quick way to learn something. It's all absorbed over a period of time, in a way that makes sense to you. Let's take a look at this sample code. Don't try to understand any of the functions, just look at it and then we'll go over what is Key and what can be manipulated:

go {
     var %tmp.1 = blah
}

If you can notice all of the Key and Manipulatable things already, that's wonderful. Most people can't tell right away. Let's break this thing apart, and see what makes it tick.

go {

We must say that this was put into the Aliases section of the mIRC editor. The word go is now an Alias, believe it or not. Any letter/number combination followed by an evaluation, in this case it is checking to see what two channels the user wants to join, is an alias; all you have to do is notice this.

var %tmp.1 = blah

Var is an mIRC command; it needs information provided to it. The key information is normally the variable, the Equal= Sign and the information that you want to make it be. In the Var alias, the %NameHere is needed. Most words in mIRC that start with % are known as Variables. Variables can be lots of names, like %My_Custom_Variable, or %MyCustomVariable. However the variable looks is up to you. Just remember, a variable that is critical should always be something. For example: If you made a command that allowed a user to join a channel, you wouldn't want the command to execute if the user didn't enter a channel to join. This type of process is called Error-Checking. You're basically checking for errors, or problems in the user input. You will learn all about this later in the tutorials. I know it all sounds good now, but you need to take it one step at a time or it will get confusing :-)

Do you see how once I made the go { command, the line until the closing } was indented? This is how mIRC lets you know that a command was issued, and lets you cluster the functions. Take a look at this simple thing:

go {
     echo -s blah
     if (whatever isin whateverHA) {
          echo -s BLAH2
     }
     echo -s blah3
}

Do you see how it is broken up? Every function is grouped using these
{ }
. This makes it easier to understand where commands are and what-not. Some commands can evern be short, and not even need the
{ }
, like this:

go echo -s blah

You see? This will do the same thing, but sometimes it will get confusing. Normally, the way you know if a command, alias, or whatever is the
BASE function, or the beginning of the function, it will be pressed ALL THE WAY up against the LEFT side of the mIRC Editor. It won't pop out. So, look at this:

go {
     echo -s blah
}

The echo -s blah is inside of the command go. How about if we look at a larger one again:

go {
     echo -s blah
     if (blah isin blah) {
          echo -s blah2
     }
}

Everything that is spaced over from the left of the Editor is inside of the go { } function. Do you see what I mean? You can easily tell whether or not if you see an Alias or not. mIRC works like this, everything is evenly spaced for you. Can you recognize the beginning of these next few lines?

go {
     echo -s blah
}

Can you see what it is? That's right! go { is the beginning. What about the end? Yep, } is the end of it. Okay, what about this one:

go {
     echo -s blah
     echo -s Hi!
     echo -s BYE!
}

Do not let anything fool you; stick with what you know about aliases. The ones that are all the way up to the Left wall of the Editor are the beginning. Okay, let's look at a more difficult one (You can do it, come on!):

go echo -s blah!

Can you see the beginning of it? If you said go then you are EXACTLY right! If you see these single-line aliases, you can tell when the alias name ends by the 'space' between the first word all the way at the left of the Editor and the next word. Aliases can be grouped with the { } even on single lines, just like this:

go { echo -s blah! }

This will work for you if you try it in the alias section of mIRC. Did you know that you can change the 'blah!' text to whatever you want? Go ahead, try it. Try making it: My name is (YOU PUT YOUR NAME HERE WITOUT THE PARANTHESIS). That would echo your name to the status screen in mIRC.


Language: Beginner's Debugging


We've looked at all of the key things in order to group your information successfully in mIRC. Let's now take a look at a few Basic Beginner debugging tests (Note: In case you didn't know, debugging means to figure out what the problem is with a certain line of script and fix it; in other words, remove the bug from it). That said, let's dive right in. Can you you tell me if this line of script will work?

go { echo -s blah!

Answer: No!. Hopefully, you answered no to this question. Do you remember what the rule is for using an alias that is grouped with the { }? It needs to open with a { and end with a }. Does this follow those rules? No. What is missing? That's right! The ending }.

What about this? Will this let us type in /go and then make it echo blah! to the status screen?

go
echo -s blah!

Answer: No!. Why not? Well, we are using two lines here; you need to group your aliases within the { } if you are going to make it multiple lines. There is a trick way to doing this, but we will learn it later.


End Section


You've practice the language just a little bit. We haven't gotten too difficult at this point; everything is taken step-by-step so that way you basically have an urge to understand it rather than just needing to understand it. This was a pretty difficult section to understand. If you got through it okay, you really deserve a pat on the back. Most people have a hard time understanding everything right away. Don't worry, you will get the hang of it with practice and hard work. Just remember to keep your head high and don't give up!




© Copyright Ronaldsoft 1997. All rights reserved. Contact: Ronald. Powered by Ronaldsoft.