Hi, everyone.
I am a Tcl newbie. Just started learning it, a few days ago, and I am quite surprised at how easy, powerful and productive it is. I didn't want to ask help in a list because I already subscribe to so many and Tcl has been so easy until now that I thought I wouldn't need it. But this is really flummoxing me.
I am making a GUI to run sed. Why? Because I love sed, it is a good idea to practice and learn Tcl. My program will have Undo/Redo, History saving and retrieving, convenient frequently-used RE management etc.
So I have two input boxes: the first one lets you enter any sed script that you would place in quotes, like this:
sed "s/find/replace/g"
The relevant code:
if {[focus -displayof $w.userinput] == ".main.userinput.sed1"} {
set mySed $mySed1
set myResult [exec ssed "$mySed" $tempfile]
}
The second input box will let you write options like -r or -n before the scripts, so it only automates "sed". You'll have to write everything else. Like this:
sed -r -n "/find (this group)/p"
The relevant code:
if {[focus -displayof $w.userinput] == ".main.userinput.sed2"} {
set mySed $mySed2
set myResult [exec ssed $mySed $tempfile]
}
That second part doesn't work. I always get this error:
C:\PROGS\GNU\ssed.exe: -e expression #1, char 1: Unknown command: `"'
I spent a ridiculous amount of time trying to find a correct escape syntax, but couldn't make it work.
After a lot of fruitless tries, I tried this kludge:
if {[focus -displayof $w.userinput] == ".main.userinput.sed2"} {
set mySed $mySed2
set mySedRun "ssed -R $mySed $tempfile"
set myResult [exec $mySedRun]
}
... and got this error:
couldn't execute "ssed -R "s\A\XXXXXX\g" c:\windows\temp\sedition1.txt": no such file or directory
Tcl inverted my slashes!
You see "ssed.exe" so many times because I am using super-sed, but that doesn't matter. Tcl is obviously misinterpreting my exec command.
BTW, I was playing with regex and tkcon the other day and could not find a way to replace slashes with inverted slashes and/or vice-versa. Should I think there is some relation to the problem mentioned above?
Thank you for any input.
Luciano
I am a Tcl newbie. Just started learning it, a few days ago, and I am quite surprised at how easy, powerful and productive it is. I didn't want to ask help in a list because I already subscribe to so many and Tcl has been so easy until now that I thought I wouldn't need it. But this is really flummoxing me.
I am making a GUI to run sed. Why? Because I love sed, it is a good idea to practice and learn Tcl. My program will have Undo/Redo, History saving and retrieving, convenient frequently-used RE management etc.
So I have two input boxes: the first one lets you enter any sed script that you would place in quotes, like this:
sed "s/find/replace/g"
The relevant code:
if {[focus -displayof $w.userinput] == ".main.userinput.sed1"} {
set mySed $mySed1
set myResult [exec ssed "$mySed" $tempfile]
}
The second input box will let you write options like -r or -n before the scripts, so it only automates "sed". You'll have to write everything else. Like this:
sed -r -n "/find (this group)/p"
The relevant code:
if {[focus -displayof $w.userinput] == ".main.userinput.sed2"} {
set mySed $mySed2
set myResult [exec ssed $mySed $tempfile]
}
That second part doesn't work. I always get this error:
C:\PROGS\GNU\ssed.exe: -e expression #1, char 1: Unknown command: `"'
I spent a ridiculous amount of time trying to find a correct escape syntax, but couldn't make it work.
After a lot of fruitless tries, I tried this kludge:
if {[focus -displayof $w.userinput] == ".main.userinput.sed2"} {
set mySed $mySed2
set mySedRun "ssed -R $mySed $tempfile"
set myResult [exec $mySedRun]
}
... and got this error:
couldn't execute "ssed -R "s\A\XXXXXX\g" c:\windows\temp\sedition1.txt": no such file or directory
Tcl inverted my slashes!
You see "ssed.exe" so many times because I am using super-sed, but that doesn't matter. Tcl is obviously misinterpreting my exec command.
BTW, I was playing with regex and tkcon the other day and could not find a way to replace slashes with inverted slashes and/or vice-versa. Should I think there is some relation to the problem mentioned above?
Thank you for any input.
Luciano