- This topic has 4 replies, 4 voices, and was last updated 9 years, 6 months ago by .
-
Topic
-
Hello, I am working on a tcl proc to remove an obx segment if two conditions are met. For example if the value of 2382 is present in any iteration of obx.3 (first condition) and the value of CO2RR is in any additional iteration of obx.3 (second condition), remove the obx segment that contains the value of CO2RR in obx.3. The code I have will remove the segment based on the second condition. I have tried multiple ways to remove the segment based on two conditions to include nested IF’s but I cant get it to work. My code that works is based on the second condition and is below. # get message and field seperators
set msg [msgget $mh] ;# get message handle
set segments [split $msg “r”] ;# split message into a list
set fsep [csubstr $msg 3 1] ;# get field separator
set csep [csubstr $msg 4 1] ;# get sub-separator
set rmList {}
# Loop through each OBX and save the location that needs to be removed.
foreach loc [lsearch -all -regexp $segments {^OBX}] {
set obxfield [split [lindex $segments $loc] $fsep]
set obx_3 [lindex $obxfield 3]
set obxsubfld [split $obx_3 $csep]
set obx_3_1 [lindex $obxsubfld 0]
#### (if value 2382 exits – evaluate the second if statement)####
#if value CO2RR exits – remove segment with this value
if {$obx_3_1 eq “CO2RR”} {
lappend rmList $loc
}
}
# remove segment
foreach loc [lsort -integer $rmList] {
lvarpop segments $loc
}
msgset $mh [join $segments r]
return “{CONTINUE $mh}”
Appreciate any help!!
😀
- The forum ‘Cloverleaf’ is closed to new topics and replies.