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

Guide to TCL scripting for Eggdrop 1.6

[ Previous ] [ Index ] [ Next ]

12.3 Checking for strings

When you try to access a string that doesn't exist TCL will give an error, because of that being able to check if a string exist in advance is very usefull. This can be done with the info exists command.
The syntax of a info exists command is info exists <string>.

The <string> is the name of the string you want to check.
If your string is an array you can either just check if the array exists or check if a specific string within the array exists, so both "test" for the array and "test(what)" for the string "what" in the array "test" specifcally are both valid.

The info exists command returns a 1 if the string exists and a 0 if it doesn't.
For example, if you would do set test(foo) "bar" and you would use info exists test it would result in a 1 and info exists test(foo) would result in a 1 aswell, so you can either check the array itself or a string inside of it.

[ Previous ] [ Index ] [ Next ]

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