Here is the code that I have been testing with. It searches the string for double or single quotes and sees if they are odd. If they are odd then it appends a single or double quote at the end of the message. The source file is tab delimited, I still have an issue with the modified message
keylget args MSGID mh
set msg [msgget $mh]
set message [split $msg r]
set double [regsub -all ” $message {} ignore]
set single [regsub -all ‘ $message {} ignore]
if {$double%2} {
set db 1
}
if {$single%2} {
set sin 1
}
if {[cequal $db 1] && [cequal $sin 1]} {
set beg [crange $message 0 end-5]
set end [crange $message end-4 end]
set new “$beg$dbl$sing$endr”
msgset $mh $new
} elseif {[cequal $db 1] && ![cequal $sin 1]} {
set beg [crange $message 0 end-5]
set end [crange $message end-4 end]
set new “$beg$dbl$endr”
msgset $mh $new
} elseif {![cequal $db 1] && [cequal $sin 1]} {
set beg [crange $message 0 end-5]
set end [crange $message end-4 end]
set new “$beg$sing$endr”
msgset $mh $new
} else {
}
lappend dispList “CONTINUE $mh”