› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Using TCL to filter on 2 conditions (SYNTAX ERRORS?)
if {} {
} else {
}
looks ok.
Couple o’ things though…
Since you
to do a case insensitive comparison.
The comment says it’s a post-xlate only proc; why go through all of the
overhead of the list-searching regexp commands? If your lmatch -regexp
is guaranteed to work, you only have the one OBR; your PV1 will be the
first one in the list (are you really going to have a variable number?) Can
you just lindex into the segments list to grab them based on position?
Why not just test for the least-likely-to-be-true condition, and if it is
test for the other, instead of doing three logical operations and then comparing?
First you say:
I am writing a proc to filter messages for a physician mnemonic (ROUST) where they only want messages to cross from one Location of Care (L.ADMED).
Then you say:
# Purpose: Kills all messages where OBR.16=”ROUST” AND PV1.3 IS NOT “L.ADMED” LOC ***(only use POST-XLATE)***
If the first statement is correct, and you only want message to cross from L.ADMED, then take out the “!” from the first IF statement where you are setting the variable “condition2”.
Hope this helps…
Tom Rioux
if {![string equal -nocase $subField L.ADMED]} {set condition2 true}
Here’s an easy way to test your logic. My apologies if you already know this.
Pull out some of the code to test it out on the command line like this:
# Kills all messages where OBR.16=”ROUST” AND PV1.3 IS NOT “L.ADMED”
set obr16 “ROUST”
set subField “L.ADMED”
set condition1 “false”
set condition2 “false”
if {[string equal -nocase $obr16 “roust”]} {set condition1 true}
if {[string equal -nocase $subField “L.ADMED”]} {set condition2 true}
puts “condition1: $condition1”
puts “condition2: $condition2”
if {[string equal -nocase $condition1 true] && [string equal -nocase $condition2 false]} {
puts “kill the message”
} else {
puts “keep the message”
}
Put that code into tmp.tcl, and then from the command line type “tcl tmp.tcl”. Then make adjustments to the script until you get the logic working the way you want it to.
-- Max Drown (Infor)
Please Wait ……
Command Issued: hcitpstest -r run -f len10 -c sms_ib_data -e “hcitpstestshowbydisp ” e:/quovadx/qdx5.4.1/integrator/okprod2/roust-rad-no.len “only_roust_admed”
Command output:
[0:TEST] Tcl error:
msgId = message0
proc = ‘only_roust_admed’
args = ”
result = ‘wrong # args: no script following “{[string equal $condition1 true] && [string equal ” argument’
errorInfo: ‘
wrong # args: no script following “{[string equal $condition1 true] && [string equal ” argument
while compiling
“if {[string equal $condition1 true] && [string equal $condition2 true]}”
(“run” arm line 49)
invoked from within
“switch -exact — $mode {
start {
# Perform special init functions
# N.B.: there may or may not be a MSGID key in args
…”
(procedure “only_roust_admed” line 6)
invoked from within
“only_roust_admed {MSGID message0} {CONTEXT sms_ib_data} {ARGS {}} {MODE run} {VERSION 3.0}”‘
I’m really frustrated because I believe it’s syntatically correct and I think everyone said the logic looks correct as well. Anything I might have overlooked? TIA.
I had moved my begin bracket ” { ” to the next line and TCL complained.