bogus strMsgId ‘message0’

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf bogus strMsgId ‘message0’

  • Creator
    Topic
  • #51170
    Kevin Crist
    Participant

    i keep getting this error when running this tclproc. It seems to be working but get the returned bogus strMsgId ‘message0’. I have done some searching found that it is because you are returning more than one mh. i have played around with different scenarios with no luck. Thanks for anyhelp.

    proc tpsKillAlls_Dr { args } {

    #########################################################################################

    # Get the Connection/Proc Name for Error/Debug Messages

    #########################################################################################

    global HciConnName

    set myname “$HciConnName/[lindex [info level 1] 0]”

    set nowis [clock format [clock scan now] -format “%D – %T”]

    #########################################################################################

    # Initialize Variables Used

    #########################################################################################

    set dispList { }    ;# Disposition List Returned to Engine

    set fldSep “” ;# Field Seperator – get from MSH

    set subSep “” ;# SubField Seperator – get from MSH

    set repSep “” ;# Repeating Field Seperator – get from MSH

    set PV1pos -1 ;# Position of PV1 Segment in msg

    set PIDList

  • ;# PV1 Segment Fields in List Form

    set ConsDrList

  • ;# PV1-3 subfields in List Form            

    set AdmDrList

  • ;# PV1-3 subfields in List Form

    set defaultvalue {} ;# Value in table when no his is found

     

     set ConsDrLocation 9 ;# Bed number is in field 3 in PV1

     set AdmDrLocation 17 ;# Bed number is in field 3 in PV1

     set table “Alls_Dr” ;# Table with Dr. number in it.

     

    #########################################################################################

    # Switch based on what mode the engine was in when it called the procedure

    #########################################################################################

    keylget args MODE mode             ;# The mode the engine called from

     switch -exact — $mode {

      start { }

       run {

        set mh [keylget args MSGID] ;# Get message handle from args

       set dispList

      ;# Initialize to good message

           set msg [msgget $mh] ;# Get a copy of the message

           set fldSep [string index $msg 3] ;# Field Seperator

           set subSep [string index $msg 4] ;# Sub-Field Seperator

           set repSep [string index $msg 5] ;# Repeating Field Seperator

      set segList [split $msg r] ;# Split message into segList

      #########################################################################################

      # Find Position of Segments – If missing -> Error out Message and Return

      #########################################################################################

      set PV1pos [lsearch -regexp $segList {^PV1}]

      if { $PV1pos < 0 } {      msgmetaset $mh USERDATA “Required Segment PV1 Missing!”  echo n n n   echo “:WARN – PV1 Segment Missing !”  echo “:WARN – Sending Message to error db.”  echo “:WARN – Here Is: $myname”  echo “:WARN – Now Is: $nowis”  echo $msg  echo n n n            set dispList

             return $dispList

      }

      #########################################################################################

      # Pull out the dr fields and get the Affinity Dr. code

      #########################################################################################

       set PV1List [split [lindex $segList $PV1pos] $fldSep]

       set ConsDrList [split [lindex $PV1List $ConsDrLocation] $subSep]

      set AdmDrList [split [lindex $PV1List $AdmDrLocation] $subSep]

      set ConsDr [split [lindex $ConsDrList 0] $subSep]

      set AdmDr [split [lindex $AdmDrList 0] $subSep]

      #########################################################################################

      # Check the Dr. Code with the Alls_Dr.tbl and see if it is a match. If there is a match

      # then the message would pass, else kill it.

      #########################################################################################

        set value [tbllookup $table $ConsDr]

        set value2 [tbllookup $table $AdmDr]

        if {[string equal $value “YES”] || [string equal $value2 “YES”]} {

            lappend dispList “CONTINUE $mh”

            } else {

            lappend dispList “KILL $mh”

            }

           

           

      #########################################################################################

      # Rebuild msg and store at mh for engine

      #########################################################################################

         lset ConsDrList [join $ConsDr $subSep]

         lset AdmDrList [join $AdmDr $subSep]

      #      echo ConsDrList:$ConsDrList    

      #      lset PV1List $ConsDrLocation $ConsDrList

      #       lset PV1List $AdmDrLocation $AdmDrList

         lset segList $PV1pos [join $PV1List $fldSep]

         msgset $mh [join $segList r]

           

      }

         time { }

         shutdown { }

      } ;# End Switch

      return $dispList

      } ;# End Proc

Viewing 7 reply threads
  • Author
    Replies
    • #69020
      Levy Lazarre
      Participant

      Kevin,

      From what I understand, you are doing a table lookup on two fields. If the lookup returns YES, you CONTINUE the message; if not, you KILL the message.

      I am not sure what you are trying to achieve with the “Rebuild msg” section but it’s in the wrong location (if needed at all).

      In the IF section, you have already disposed of your original message by continuing or killing it. Now in the “rebuild” section, you set the content for what becomes a new message but there is no disposition for it. Cloverleaf doesn’t know what to do with it.

    • #69021
      Kevin Crist
      Participant

      I was under the impression if you pull out a field you have to join them together… would i do that before the continue of killing of a messge. I understand if it kills the message but was unclear of the continue part.

      Thanks. I have another question if you have time and know the answer:

      In the code below, i am trying to use the PID in with the other segments, but apparently pid is a tcl command ( i wasnt aware of that) so when i type in PID it automatically makes it lower case pid. is there a way around this or maybe it’s my editor? i am using ultra edit, this one has me stumped.

      thanks.

      ###############################################################################

      ###############################################################################

      # #

      # Find Position of Segments that contain Name Positions #

      ###############################################################################

      ###############################################################################

       

               lappend PosList [lsearch -regexp $segList {^pid}]

               lappend PosList [lsearch -regexp $segList {^NK1}]

               lappend PosList [lsearch -regexp $segList {^GT1}]

               lappend PosList [lsearch -regexp $segList {^IN1}]

    • #69022
      Levy Lazarre
      Participant

      Kevin,

      If you pull a field just to query its value, you don’t make any change to the segment, so you don’t have to put anything back together. Therefore, you can delete the “Rebuid msg” section completely. It’s not needed.

      Indeed, “pid” is a Tcl command that retrieves process identifiers. I don’t use UltraEdit, so I don’t know how to turn off this “auto-help” feature but you could do several things:

      1. Edit the file in UltraEdit as a text file instead of a tcl file.

      2. Or, after you save the file from UltraEdit with the ^pid, import it in Cloverleaf, load it in the Cloverleaf editor, and make the change there.

      3. Use another editor. My preferred freeware one is PSPad from http://www.pspad.com

      I hope this helps.

    • #69023
      David Barr
      Participant

      Levy Lazarre wrote:

      In the IF section, you have already disposed of your original message by continuing or killing it. Now in the “rebuild” section, you set the content for what becomes a new message but there is no disposition for it. Cloverleaf doesn’t know what to do with it.

      I don’t think that’s the problem.  Putting the message in the dispList doesn’t actually get rid of the message until the proc returns.  You can still perform operations on a message that you’ve put in a dispList.

      The problem is that he is initializing dispList to “CONTINUE $mh”, then at the bottom of the code he is doing ‘lappend dispList “CONTINUE $mh”‘.  So, the final dispList being returned is “{ CONTINUE message0 } { CONTINUE message0 }”.

    • #69024
      Levy Lazarre
      Participant

      I think I am getting confused.

      He initialized dispList to an empty list at the beginning of the proc:

      set dispList { }    ;# Disposition List Returned to Engine

      The lappend will add either “CONTINUE” or “KILL” to this empty list, so only one value will be in the returned dispList.

    • #69025
      Kevin Crist
      Participant

      Thanks guys, i was able to get this working. I took out the rebuilding message part…thanks for clearing that up for me, will make things easier down the road. I also took out the line:

      set dispList

        Initialize to good message.

        I had copied another proc and was modifying it to my needs and totally overlooked that one in the middle. Thanks.

    • #69026
      Bob Richardson
      Participant

      Greetings,

      Just a coding technique that I use when initializing dispList to return the dispostion of a message handle:  I use the “unset dispList” Tcl instruction to destroy the original variable instance and then recreate it with the new value.  

      I suppose it “wastes” TCL interpreter time but has proven to be useful when making decisions in the logic to “reset” the final disposition of a message handle.

      For example:

      # **** Initialzation ****

      lappend dispList “CONTINUE $mh”

      # **** Runtime ****

      unset dispList

      lappend dispList “KILL $mh”

      # **** Error ****

      unset dispList

      lappend dispList “ERROR $mh”

      Have a great weekend!

    • #69027
      Levy Lazarre
      Participant

      Bob,

      I think that your technique is safe and is worth the extra statement.

      If my understanding is correct, mh is a pointer to an area in memory. I suspect that when we use “msgset”, we are reusing the mh variable and pointing it to a different area in memory. So I think that any “lappend dispList” command should be issued after, not before the msgset statement.

Viewing 7 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forums

Forum Statistics

Registered Users
5,115
Forums
28
Topics
9,290
Replies
34,422
Topic Tags
286
Empty Topic Tags
10