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

Guide to TCL scripting for Eggdrop 1.6


[ Previous ] [ Index ] [ Next ]


3.3 Interpretations

Like all programming languages you have to place certain events between special characters to let the language know what to do with your event. TCL uses the following characters to define events:

<> - the greater than and is less than signs
These two signs aren't used in TCL itself, but it is used in documentation to indicate that a parameter is required if you want to execute the command.

"" - quotes
Quotes are used to mark text. Everything between quotes is considered to be text,
except when it is enclosed in brackets or is marked as a variable (you will learn about variables later on).

[ ] - brackets
Brackets are used to execute commands. The first word inside the brackets is the command that you want to execute and the rest are the parameters of the command.
They are also used in documentation to indicate that a parameter is optional and not required to run the specified command.

{ } - braces
Braces are used to indicate where something starts and stops. This can be a part of the script or a command for example.

( ) - parentheses
Parantheses are used to define multiple things. It is used to declare that a variable is an array and that certain parts of the if command belong together for example (how this works and what it is will be explained later on).

$ - variable
This defines that the word directly following the $ (without seperation of a space) is a variable.
Shortly said a variable is a place where you store information in to call upon it later. This will be discussed more extensive later on aswell like I said above.

; - semicolon
When TCL sees a semicolon, it processes everything behind it as if it were on a new line. This way you can put more than one command on a single line to make your script shorter and still let it work.
If you don't use a semicolon and put a second command behind your first one, TCL will see it as extra comment for the command in front of it and will give (most likely) an error because the command isn't supposed to have such a parameter or it makes your script malfunction.

# - hash
When TCL sees a hash at the beginning of a line, it considers everything behind it as comment and will ignore it and skip to the next line.
Many programming languages allow you to say where the comment starts and stops, like in HTML you define the start of comment with <!-- and where the comment stops with --> or like in C where you let the comment start with /* and let it stop with */.
This doesn't apply for TCL. When you have put a hash at the beginning of a line, everything behind it (on that line) is ignored. Please note that you can not put a hash in the middle of a line and put comment behind it, this will give an error because TCL doesn't see it as comment in that case.
Instead, you can put a semicolon in front of your hash so that TCL will interpret the things behind it as they were on a new line and then it will see it start with a hash and thus will consider everything behind it as comment.
It's a bit complicated, but that's just the way it is and I don't think that it will ever change, you'll get used to it ;). Once you realize how it works it's not that difficult.

\ - backslash
A backslash is used to let TCL see the next character as text. Normally when you would put a bracket in your script TCL would see it as the start or end of a command, but when you put a backslash in front of it, TCL will see it as plain text and process the bracket instead of trying to execute a command.
There are several exceptions to this though. There are a few codes that start with a backslash, followed by a number or letter to create a special character. In those cases the backslash means that there is a special code and not to see the next character as text.
For example: \0 (that's the number 0, not the letter o) normally would make TCL see the 0 as text (TCL sees an 0 in general as text already, but the backslash enforces it and this is mearly an example to explain how it works), but \037 doesn't mean 037 with the 0 enforced as text, but it means that the following text must be underlined.
This might seem a bit confusing aswell but once you get a grasp on how it works it's not so hard anymore like is with most things in TCL.

For the rest all the commands and small examples within the text will be shown in italic, so that they can easily be distinguished from comment and other text.
Bigger examples will be shown in a different font and on seperate lines.


[ Previous ] [ Index ] [ Next ]

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