The TCL script language isn't something from Eggdrop specifically. It's a standalone language used by
Eggdrop. To help you understand things better later on, this will be a chapter about what TCL exactly is and
what it does.
TCL is an open source language. This means that your program is run by sending the source code (the script
itself) of it to the TCL program which processes it, without compiling it unlike languages like C. This means
that people can always look at your programs source code and see how it is written, because of this you will
have less problems with incompatibility on different computers because the TCL language is always the same.
The commands of a TCL script can roughly be divided into two parts. The first part is executed when you run
the script and the other part is executed when you call upon it.
Commands which are executed when the script starts are outside a procedure (I'll explain later on how you
can define procedures).
In a TCL script are (in general) multiple procedures. The commands within these procedures are only executed
when the procedure is triggered. A procedure can be triggered in two ways, either by calling upon it yourself or
when an event is triggered that's bound to the procedure.
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.
Because TCL is not just something from Eggdrop, there are two types of commands. Commands of TCL itself that
will work on scripts outside Eggdrop aswell and commands that have been added by Eggdrop.
All the commands that Eggdrop adds to the TCL language are listed in tcl-commands.doc, which can be found in
the doc/ directory of Eggdrop.
You can get information about a TCL command from the manpages. You can access the manpages by typing
man n <command> on a *nix computer which has the TCL manpages installed or browse through the HTML
version of the manpages at http://dev.scriptics.com/man/tcl8.0/TclCmd/contents.htm.
|