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

Guide to TCL scripting for Eggdrop 1.6

[ Previous ] [ Index ] [ Next ]

4.4 Ending a procedure

Next to of course just ending the body of your procedure with a close-brace, you can use the command return to let the procedure end anywhere within the body. How the procedure will end depends on how you use the return command.
The basic syntax of the return command is return <message>.

The <message> is what the procedure must output. In general you end the proc with either 0 or 1 as <message>.
In most cases using 0 as <message> will result in a quiet return where the bot goes it's normal way as it would do if the bind didn't exist, meaning that it won't log anything and won't override built-in features like flood protection for example either.
When you are returning with 1 the bot usually either logs the command that has been performed by i.e. a bind dcc or it doesn't react itself on the event (when you are using bind flud for example, returning 1 will make the bot not react on the flood but let the TCL script handle it entirely).
You can find more in tcl-commands.doc about how the different binds react on which return value.

Besides 0 or 1 you can also have the procedure return text if you want.
That would make the procedure roughly said an interactive variable. You would still have to call upon it like proc [parameters], but it would return information like a variable would.
For example, proc test { nick } { return "Hello $nick." } would be the same as set test "Hello $nick.", only you would call upon them differently and you could let the procedure check things and possibly output something different than the input, but still having the output like it's a variable.

[ Previous ] [ Index ] [ Next ]

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