When executing "lappend list \[something\]" it will be added to list as [something] instead of \[something\] as I want it.
Can anyone code a "string map" or "regexp" which would convert \[something\] to \\\[something\\\] ? so when "lappend list \\\[something\\\]" is executed, \[something\] will be added to list.
I Hope I was clear enough, and note that \[something\] would be in a var (ofourse, that's why I need the "string map" or "regexp" )
I've just realized that it doesn't matter whether its $var or ${var} sorry for the mistake, my problem seems to be something else (I was testing it directly on "lappend list \[this\]" instead of $var).
I have a code to remove nicks from a file, but nicks with \ don't seem to be deleted, Here's the code:
proc spn:rem {hand idx arg} {
global spnfile spf
if {$arg == ""} { return 0 }
set spnick "[string map {\\ \\\\ \[ \\\[ \] \\\]} $arg]"
## exists:spnick checks if $spnick exists in file and set spf to 1 if found.
exists:spnick $spnick
if {$spf == "1"} {
set list ""
set file [open $spnfile r]
while {![eof $file]} {
set nick [gets $file]
if {![string equal -nocase $nick $spnick]} { lappend list $nick }
}
close $file
set ofile [open $spnfile w]
foreach snick $list {
if {$snick != ""} { puts $ofile $snick }
}
close $ofile
putlog "$spnick was deleted."
} else {
putlog "$spnick doesn't exist."
}
}