Originally posted by Roman Partigula
I want to filter our messages and save all discarded ones to an error file
Following is tps routin I want to use to do this.
errorFile is supposed be opened only ones when this connection gets started
and gets closed during shutdown
My problem is that RUN part of my routine doesn't recognize myfileID defined in START
Can anybody tell me please what I do wrong?
Or may be it is another way how to do it?
Thanks
proc FilterParse { args } {
package require medisyslib
global HciSiteDir
set errorFile $HciSiteDir/exec/processes/kicout/IBfiles/picisChgError.txt
keylget args MODE mode ;# Fetch mode
set dispList {} ;# Nothing to return
switch -exact -- $mode {
start {
set myfileID [ open $errorFile APPEND ] }
run {
keylget args MSGID mh
set msg [msgget $mh]
set fieldsep [ crange $msg 3 3 ]
set segmlist [ split $msg r ]
set mshSegm [ getSegment $segmlist "MSH" ]
set mshFieldList [ split $mshSegm $fieldsep ]
set facility [ lindex $mshFieldList 3 ]
if { [ cequal $facility "JHMC" ] } {
lappend dispList "CONTINUE $mh"
} else {
msgwrite raw $mh $myfileID lappend dispList "KILL $mh"
}
}
time {
# N.B.: there may or may not be a MSGID key in args
}
shutdown {
# Doing some clean-up work
close $myfileID}
}
return $dispList