Due to the way some chars work in TCL, they need to be corectly handled. {}[];$ are a few of these chars.
No regsub is required, just the corect useage of a few commands.
When taking input, use the split command. This will make sure that none of the text is interprited as a commands or anything else.
When writting it to file, use the join command, this will make sure it is written corectly.
EG, lets take a string of text from a channel, and put it into a a list (what you refer to as an array, is actualy a list).
Code: Select all
bind pubm - * test:proc
proc test:proc {nick uh hand chan arg} {
global mylist
lappend mylist "[split $arg]"
}
yes, this will mean that ; becomes {;}, but that doesn't matter, as it means the script is corectly storing things.
To write to file, we can now use
Code: Select all
proc writefile {} {
gloabl mylist
set fp [open "some.file" w]
foreach a $mylist {
puts $fp "[join $a]"
}
}