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

Guide to TCL scripting for Eggdrop 1.6

[ Previous ] [ Index ] [ Next ]

8.7 Converting strings into lists

You can convert a string into a list with the split command.
The syntax of a split command is split <string> [character].

The <string> is the string you want to convert, which can be a string or a command that outputs a string.

The [character] is the character that will be used for splitting the string into objects.
Whenever split encounters the given character it will see it as a marker for the end of an object and the start of a new one.
If no character is provided a space is used to split the string.

The split command returns a newly compiled list in which the first object is everything in the <string> up to the [character], the second object everything between the second and third [character] and so on.
Any braces that are in the <string> will be considered a part of the object and new braces or backslashes will be added to enforce that the brace is a part of the object if neccesary.

A small example: split "test {foo bar} temp" would result in a list where the first object would be "test", the second "{foo", the third "bar}" and the fourth "temp". Also split "test.{}.temp" . would result in the same thing.

[ Previous ] [ Index ] [ Next ]

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