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

Guide to TCL scripting for Eggdrop 1.6


[ Previous ] [ Index ] [ Next ]


8.3 Retrieving an object from a list

Gettings object from lists is fairly easy. The command for this is lindex.
The syntax of a lindex command is lindex <list> <number>.

The <list> is the list from where the object must be retrieved.
This can be anything from a string containing a list ($test can contain a list for example by putting the output of a list command in it with set) to a command, just as long as it's a valid list and not a plain string.

The <number> is the number of the object you want to retrieve.
Each object in the list has its own number, starting at 0. The first object is 0, the second 1, the third 2, and so on. It's a bit confusing, but if you're used to programming this will seem familiar.

A small example: lindex $test 5 returns the 6th object from the list that is in $test.

The lindex command outputs a string containing only the object itself without the open and close braces that mark the start and stop of the object if those are present in the list.


[ Previous ] [ Index ] [ Next ]


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