This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Help for those learning Tcl or writing their own scripts.
keeper2
Voice
Posts: 12 Joined: Wed Jul 19, 2006 10:16 am
Post
by keeper2 » Wed Jul 19, 2006 10:25 am
OK I am new to TCL scripting, I come from the mirc scripting camp
.
I already read some articles about scripting in TCL, but don't find a answer to these two questions.
1. Is there a command like gettok in TCL so you can cut a string lets say:
This-is-a-test
into
This
is
a
test
and access all of these strings seperatly
2. I have a Textfile in which in each line a nickname is. Now I want to search the Textfile for a nick and if it is found that the TCL script do sth.
keeper2
Voice
Posts: 12 Joined: Wed Jul 19, 2006 10:16 am
Post
by keeper2 » Wed Jul 19, 2006 10:35 am
Thanks, but when I have the whole Textfile in data how to search for a specified string?
krimson
Halfop
Posts: 86 Joined: Wed Apr 19, 2006 8:12 am
Post
by krimson » Wed Jul 19, 2006 11:21 am
you can use something like this
Code: Select all
set openfile [open "path/to/your/file" r]
set data [read $openfile]
foreach line [split $data \n] {
if {$line == nick1} {
#perform whatever commands
} elseif {$line == nick2} {
#perform other commands
} else {
#another set of commands
}
}
metroid
Owner
Posts: 771 Joined: Wed Jun 16, 2004 2:46 am
Post
by metroid » Thu Jul 20, 2006 1:18 am
don't forget to close the file.
Code: Select all
set openfile [open "path/to/your/file" r]
set data [read $openfile]
close $openfile
foreach line [split $data \n] {
if {$line == nick1} {
#perform whatever commands
} elseif {$line == nick2} {
#perform other commands
} else {
#another set of commands
}
}