- This topic has 4 replies, 3 voices, and was last updated 15 years, 5 months ago by .
-
Topic
-
I’m somewhat new to tcl, so please bear with me… I’ve got a TPS Proc that references a message handle. I find that when I pass the message handle as an argument to a “local” proc that any modifications made to the message handle are global. This surprises me as I thought you couldn’t pass by reference unless you used “upvar”.
Specifically, if I pass $newmh as an arg to my local proc, where the local proc does a msgappend, the message header retains the changes in the “main” proc. I had expected the changes to the message header in the “local” proc NOT to be retained in the “main” proc due to scoping…
Is there some unseen environment setting in TPS procs that allow for this, or am I just missing the obvious?
thanks,
Steve
Here’s my “local” proc, in the same file as my TPS proc, followed by the TPS proc that calls the “local” proc –
processAOE: Code:proc processAOE { mh obx debug } {
# get the test code type
set comp [getHL7Comp $obx 3 1]if {$debug} {
# name of this procedure
set module [lindex [info level [info level]] 0]echo “in $module: OBR:3.1 = $comp”
}# build a new obx containing the question & answer
switch — $comp {
do some stuff here…# just add the segment and we’re done
msgappend $mh $obx
msgappend $mh “r”
}
}
}proc breakout4medicaAOE { args } {
global env HciSiteDir HciConnNamekeylget args MODE mode ;# fetch mode
set dispList {} ;# nothing to return
switch -exact — $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
}run {
# defaults
set debug 0# get debug flag
keylget args ARGS.DEBUG debug# ‘run’ mode always has a MSGID; fetch and process it
keylget args MSGID mh# get the msg
set msg [msgget $mh]… do stuff here
set newmh [msgcopy $mh]
# set the message data to null, since we’re generating a new msg
msgset $newmh “”… do more stuff here
# process the OBX segment if it’s prenatal
if { $prenatal && [cequal $seg “OBX”] } {# CALL processAOE HERE – no return value to save…
processAOE $newmh $segment $debug} elseif { $seg != “” } {
msgappend $newmh $segment
msgappend $newmh “r”
}
}if {$debug} { echo “new msg is:n[msgget $newmh]” }
# send the new msg on
lappend dispList “CONTINUE $newmh”# and kill the old msg
lappend dispList “KILL $mh”
}
…
- The forum ‘Cloverleaf’ is closed to new topics and replies.