I have a request for conver encoding character for NTE:3 field.
I wrote a script in TCL and can convert all encoding characters except Pipe “|”. My code is below. my code is below.
if there is a Pipe “|” inside the field value, is it possible to convert it?
is there a way we could do it?
thank you for your help as always!!!!
run {
# ‘run’ mode always has a MSGID; fetch and process it
keylget args MSGID mh
set msg [msgget $mh]
set segmentList [split $msg r]
set newSegmentList “”
set compsep [crange $msg 4 4]
set fieldSeparator [crange $msg 3 3 ]
foreach segment $segmentList {
if {[crange $segment 0 2] == “NTE”} {
set fieldList [split $segment $fieldSeparator]
set f3 [lindex $fieldList 3]
regsub {|} $f3 {\F\} f3
regsub {~} $f3 {\R\} f3
regsub {^} $f3 {\S\} f3
regsub {\} $f3 {\E\} f3
regsub {&} $f3 {\T\} f3
set fieldList [lreplace $fieldList 3 3 $f3]
set segment [join $fieldList $fieldSeparator]
} else {
# no change
}
set newSegmentList [lappend newSegmentList $segment]
}
set msg [join $newSegmentList r]