Thanks Charlie, apologies for the sparse details on the original post. So, I went with a switch statement to cover the logic since there were a handful of potential options. At this point I’m trying to create or append a newline terminated file, which is created if it doesn’t already exist. I’m thinking that the code for each scenario in the switch statement would first check to see if the file exists. If not, create it (newline, append). After the check/creation, open, write the message to the to file, and close. I’m just not sure how to actually code this. If you have any pointers, it’s much appreciated. Thanks!
###########################################
keylget args MSGID mh
set msg [msgget $mh]
set fieldSep [string index $msg 3]
set subSep [string index $msg 4]
set segList [split $msg r]
set segment [lsearch -inline -regexp $segList ^RXA]
set fieldList [split $segment $fieldSep]
set fieldList [lreplace $fieldList 6 6 1]
set segment [join $fieldList $fieldSep]
set position [lsearch -regexp $segList ^RXA]
set segList [lreplace $segList $position $position $segment]
set rxa_11 [lindex $fieldList 11]
set subFieldList [split $rxa_11 $subSep]
set rxa_11_1 [lindex $subFieldList 0]
set dest_Dir $HciSiteDir/dir/subdir/out
set msg [join $segList r]
msgset $mh $msg
switch -exact — $rxa_11_1 {
facility1 {
set fileId [open $dest_Dir/facility1 RDWR 0666]
}
facility1 {
set fileId [open $dest_Dir/facility1 RDWR 0666]
}
facility2 {
set fileId [open $dest_Dir/facility2 RDWR -0666]
}
facility2 {
set fileId [open $dest_Dir/facility2 RDWR 0666]
}
facility3 {
set fileId [open $dest_Dir/facility3 RDWR 0666]
}
facility3 {
set fileId [open $dest_Dir/facility3 RDWR 0666]
}
facility4 {
set fileId [open $dest_Dir/facility4 RDWR 0666]
}
facility4 {
set fileId [open $dest_Dir/facility4 RDWR 0666]
}
facility5 {
set fileId [open $dest_Dir/facility5 RDWR 0666]
}
facility5 {
set fileId [open $dest_Dir/facility5 RDWR 0666]
}
facility6 {
set fileId [open $dest_Dir/facility6 RDWR 0666]
}
facility6 {
set fileId [open $dest_Dir/facility6 RDWR 0666]
}
facility7 {
set fileId [open $dest_Dir/facility7 RDWR 0666]
}
facility7 {
set fileId [open $dest_Dir/facility7 RDWR 0666]
}
default {
set fileId [open $dest_Dir/DefaultFacility RDWR 0666]
}
}
echo $fileId
lappend dispList “CONTINUE $mh”
}