SUNiNET - Your Eggdrop & TCL resources site
[ Home Eggdrop TCL Links About ]

Guide to TCL scripting for Eggdrop 1.6

[ Previous ] [ Index ] [ Next ]

7.1 Matching two items against each other

With the if command you can make the script perform a set of commands only when something you specify is equal or not to something else.
This can be a command that has to be performed, two strings, practically anything. I don't know how I can explain this very well in words, but it's a simple command once you understand it so I'll just tell you how it works and give some examples to explain it later on.
The syntax of an if command is if { <action> <compare method> <action>} { <body> }.

The two <action>'s are what the if command must compare to each other.
This can be two strings, a command (don't forgot to enclose it with brackets like was told in Chapter 3.3) or some text (enclosed in quotes like also told in Chapter 3.3) or anything else that can be used to match something against it.

The <compare method> tells the if command how to compare the two actions with each other.
This can be either two things, namely == for 'is equal to' or != for 'is not equal to', when one of the <action>'s is not a number.
If both <action>'s are a number you can also use the 'is greater than' (>) and the 'is less than' (<) signs to see whether something is larger than the other (you can for example use as <action>'s two commands that calculate how many characters there are in a string which both result in a number).
Last but not least, by putting an 'is' (=) sign after the 'is greater than' or 'is less than' sign you can change 'is greater/less than' into 'is greater/less than OR is the same amount as'.

The <body> is basicly the commands you want the if command to execute.
The body doesn't have to be on one line, that's why the if command starts with an open-brace.
You can put a new command on each new line and it'll still be part of the if command until you close the body up with a close-brace just like with a procedure.

[ Previous ] [ Index ] [ Next ]

Design & Graphics by Shawn Borton
Copyright © 2000-2005 Marijn van Zon