Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Using TCL to filter on 2 conditions (SYNTAX ERRORS?)
- This topic has 7 replies, 5 voices, and was last updated 16 years, 2 months ago by Alice Kazin.
-
CreatorTopic
-
June 3, 2008 at 7:50 pm #50088Duy NguyenParticipant
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). -
CreatorTopic
-
AuthorReplies
-
-
June 3, 2008 at 8:53 pm #64858Kevin KinnellParticipant
The if {} {
} else {
}
looks ok.
Couple o’ things though…
Since
youare setting condition1 and condition2 it doesn’t seem reasonable 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
istrue test for the other, instead of doing three logical operations and then comparing?
-
June 3, 2008 at 8:54 pm #64859Tom RiouxParticipant
Well, first of all tell us exactly what you are looking for. You seem to contradict yourself with these two statements in your post and in your proc comments: 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
-
June 3, 2008 at 9:11 pm #64860Max Drown (Infor)Keymaster
I believe the problem is the negation (!) in this if statement: Code: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:
Code:# 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)
-
June 4, 2008 at 12:13 pm #64861Duy NguyenParticipant
Thanks for all the prompt replies everyone. I will have a go at it again today using everyone’s input and testing tips. =) -
June 26, 2008 at 3:30 pm #64862Duy NguyenParticipant
I’ve tried testing this in the TCL mode at the command line and of course it works. But when I go back to the testing tool, I’m getting this whenever I execute the TCL proc against my LENGTH ENCODED FILE (created from SMAT): 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.
-
June 27, 2008 at 12:26 pm #64863Duy NguyenParticipant
Well the source of the problem was at the end of my IF statement. (pointed out by a fellow Cloverleafer 🙂 ) I had moved my begin bracket ” { ” to the next line and TCL complained.
-
June 27, 2008 at 4:15 pm #64864Alice KazinParticipant
You can continue on the next line if you put “” at end of previous line
-
-
AuthorReplies
- The forum ‘Cloverleaf’ is closed to new topics and replies.