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

Guide to TCL scripting for Eggdrop 1.6

[ Previous ] [ Index ] [ Next ]

5.3 Using arrays

Besides normal strings, there are also arrays.
An array is a group of strings brought together "under one roof". You can use these arrays in exactly the same way as you can use normal strings and more.
The biggest advantage of an array over a normal string is that because they are all under the same roof they can also be processed all at once with some commands, making it easier for you because you don't have to check all your strings one by one since the entire array is already loaded.

The syntax of an array is $array(string), where array is the name of the array and string is the name of the string within the array.
Once you have created an array you can't create a string with the same name.
For example, if you have $test(<string>), you won't be able to have $test aswell.

Here are a few examples:

#Put the word "that" in the string what of the array test
set test(what) "that"

#Put the word "now" in the string when of the array test
set test(when) "now"

#The following will produce an error since there already is an array called test!
set test "testing"

#Put the word "what" in the string test_what
set test_what "what"

#Put the word "now" in the string test_when
set test_when "now"

[ Previous ] [ Index ] [ Next ]

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