I am having trouble over something that I shouldn’t be struggling with…Not sure what I am missing here.
I am trying to replace the repeating field in PV1 8 after trimming the U off. I am not able to do the replace. I cannot understand why my append in PV1 switch does work. Please advise.
foreach segment $splitMsg {
set segID [string range $segment 0 2]
switch -exact $segID {
MSH {
if {$MSHcount > 0} {
append outMsg “n$segment[format %c 13]”
} else { append outMsg “n$segment[format %c 13]”}
incr MSHcount +1
}
PV1 {
set splitSeg [split $segment |]
set PV1_8 [lindex $splitSeg 8]
set PV18_1seg [lindex [split $PV1_8 ~] 0]
set PV18_2seg [lindex [split $PV1_8 ~] 1]
set PV2_1fld “”
set PV1_1fld [string trimright [lindex [split [lindex $PV18_1seg] ^] 0] U]
set PV1_2fld [string trimright [lindex [split [lindex $PV18_2seg] ^] 0] U]
if {$PV1_1fld != “”} {
set PV18_1seg [split $PV18_1seg ^]
set PV18_2seg [lindex [split $PV18_1seg ~] 1]
set newpv18 [join [lreplace $PV18_1seg 0 0 $PV1_1fld] ^]
# set newpv18 [join $newpv18 |]
set segment [lreplace $splitSeg 8 8 [lindex $newpv18 8]]
set segment [join $segment |]
append outMsg $splitSeg[format %c 13]
}
default {append outMsg “n$segment[format %c 13]”}
}
}
incr currentCount +1
set counterOut [open /tst/cis6.0/integrator/testdev/FTP/TAMTRON/UPA/tamtronCounter w+]
puts $counterOut $currentCount
flush $counterOut
set outMsg [string trimleft $outMsg]
puts $outFile $outMsg
flush $outFile
lappend dispList “KILL $mh”
}
Thanks,
FJ