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

Guide to TCL scripting for Eggdrop 1.6

[ Previous ] [ Index ] [ Next ]

9.1 Retrieving a character from a string

This command works in exactly the same way as the lindex command, only the command is a bit different.
To retrieve characters from a string we use the command string index.
The syntax of a string index command is string index <string> <number>.

The <string> is the string from which the characters must be retrieved.
This can be anything from a string as in variable to a command.

The <number> is the number of the character you want to retrieve, where 0 is the first character, 1 the second character, 2 the third character and so on like in the other commands for lists except that it now goes per character instead of per object.

The string index command outputs a string that contains the charater you specified.
If you were to input a list which contains an object that is defined with braces, the braces will also be regarded as characters in the string and not as items to designate a start and stop of an object.
For example, string index "test {foo bar} temp" 5 would return "{" and not "f" or "foo bar".

[ Previous ] [ Index ] [ Next ]

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