This was written very quickly (heading home for the day) and was not tested…if you have some tcl knowledge, you’ll see that I’m saving the DG1 segments and not applying them to the outbound message until a GT1 segment is encountered. Again, it was written quickly and there may be better ways of doing it.
set SavedDG1 “”
set skip FALSE
set segments [split $msg r] ;# Get segments
set outbuf “” ;# Holds outbound message
foreach seg $segments {
if {[string equal $seg “”]} { continue } ;# Just in case
set segtype [csubstr $seg 0 3] ;# segment name
set skip FALSE
if {[string equal $segtype GT1]} {
set seg $seg$SavedDG1
set SavedDG1 “”
}
if {[string equal $segtype DG1]} {
append SavedDG1 $seg ;#append due to multiple DG1 segments
set skip TRUE
}
if {[string equal skip FALSE]} {
append outbuf ${seg}
}
}
msgset $mh $outbuf
return “{CONTINUE $mh}”