tcl error help

Clovertech Forums Read Only Archives Cloverleaf Tcl Library tcl error help

  • Creator
    Topic
  • #54122
    Kevin Crist
    Participant

      We have a tcl in place to remove backslashes out ADTs and have been using it in our CL5.4.1 for a long time. This same tcl does not work in our testing of CL6.0.1 and i trying to figure out why? Can anyone see what is wrong?

      Code and error are below:

      0:TEST] Tcl error:

      msgId = message0

      proc = ‘tpsFixBackSlash’

      args = ”

      result = ‘wrong # args: should be “switch ?switches? string {pattern body … ?default body?}”‘

      errorInfo: ‘

      wrong # args: should be “switch ?switches? string {pattern body … ?default body?}”

         while executing

      “switch -exact — $nextchar

         (procedure “tpsFixBackSlash” line 60)

         invoked from within

      “tpsFixBackSlash {MSGID message0} {CONTEXT sms_ib_data} {ARGS {}} {MODE run} {VERSION 3.0}”‘

      Code:


      #######################################################################################
      #######################################################################################
      #######################################################################################
      #
      # Name: tpsFixBackSlash.tps
      # Purpose: This procedure fixes messages with the special character “” in them.
      # This was needed because messages from affinity going to infinity had the
      # “” in the message and it stops the inbound connection with infinity.
      # When this happened in the past, we needed to delete the message
      # and bounce the hl7 interface.  The messages will now be fixed.
      # If the “” is the last character in a field or subfield, it is deleted.
      # If it is in the middle of the field, it is replaced with a “-”
      #
      #
      # UPoC type: tps
      # Args: tps keyedlist containing the following keys:
      #       MODE    run mode (”start”, “run” or “time”)
      #       MSGID   message handle
      #       ARGS    user-supplied arguments:
      #
      # Returns: tps disposition list:
      #
      # John Zalesak 01-08-2009
      # Created
      #
      # John Zalesak 01-15-2009
      # Modified message in engine log so we can see it better
      #
      # John Zalesak 02-27-2009
      # This tps procedure was recently moved to prod100 and was put in place
      # to look at all ADTs coming from Affinity and fixes the ADTs going to all systems.
      # Updated the error message in the eninge log today.
      #
      #
      #######################################################################################
      #######################################################################################
      #######################################################################################

      proc tpsFixBackSlash { args } {

      #######################################################################################
      # Setup some globals used
      #######################################################################################

      global HciConnName
      global HciRoot
      global HciSite

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

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

      #######################################################################################
      # Initialize Variables Used
      #######################################################################################

      set dispList {} ;# Disposition List Returned to Engine
      set badchar \ ;# Bad Character to Look for
      set charloc 0 ;# Location of offending character
      set nextloc 0 ;# Location of Char after bad char
      set newchar “” ;# Replace bad char with this
       
      #######################################################################################
      # Load in the arguments we need that were passed from the caller
      #######################################################################################

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

      #######################################################################################
      # We only want to take action if called from the run mode
      #######################################################################################

      switch -exact — $mode {
      start { }

      run {

      set mh [keylget args MSGID] ;# Get message handle from args
         set dispList [list “CONTINUE $mh”] ;# 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

           
      #######################################################################################
      # Search for “” and if found correct
      #  Start at location 8 to get past field seperator definitions
      #######################################################################################

           while {[set charloc [string first $badchar $msg 8]] != -1} {
           
            set nextchar [string index $msg [expr $charloc + 1]]
           
            switch -exact — $nextchar
            $fldSep –
            $subSep –
            $repSep –
            “r” {set newchar “”}
            default {set newchar “-“}

      echo “:WARN ”
      echo “:WARN ——————————————————————-”
      echo “:WARN $badchar character found coming ouf of affinity at location $charloc”
      echo “:WARN Here is $myname”
      echo “:WARN Now is [clock format [clock scan now] -format “%D – %T”]”
      echo “:WARN Original Message shown below”
      echo $msg
      echo “:WARN ——————————————————————-”
      echo “:WARN ”

      set msg [string replace $msg $charloc $charloc $newchar]

           }
           
      msgset $mh $msg

      }

         time { }
             
         shutdown { }
       
      } ;# End Switch

      return $dispList

      } ;# End Proc

    Viewing 3 reply threads
    • Author
      Replies
      • #80246
        Tom Rioux
        Participant

          Kevin,

          It appears your switch statement is missing the “{” and “}” that should enclose your switch body:

          Should be:

          switch -exact — $nextchar {

                     $fldSep –

                     $subSep –

                     $repSep –

                     “r” {set newchar “”}

                     default {set newchar “-“}

          }

        • #80247
          Kevin Crist
          Participant

            Thanks for the reply Thomas. That did the trick.  I double checked our current 5.4.1 environment and that proc is running fine without those braces there. Strange.

            Have a good weekend.

          • #80248
            Elisha Gould
            Participant

              FYI the following will not resolve the separator variables. It will compare on $fldSep not its value.

              Code:

              switch -exact — $nextchar {
                        $fldSep –
                        $subSep –
                        $repSep –
                        “r” {set newchar “”}
                        default {set newchar “-“}
              }

              You could use the following

              Code:

              switch -exact — $nextchar [list
                         $fldSep –
                         $subSep –
                         $repSep –
                         “r” {set newchar “”}
                         default {set newchar “-“}]

              OR

              Code:

              switch -exact — $nextchar [subs {
                        $fldSep –
                        $subSep –
                        $repSep –
                        “r” {set newchar “”}
                        default {set newchar “-“}
              }]

            • #80249
              Bob Richardson
              Participant

                Greetings,

                As you are jumping from 5.4.1 to 6.0 there have been TCL version changes that impact several TCL command behaviors.  You might want

                to get the release notes for the intervening releases and create a list

                of TCL commands that may have been impacted.

                Hope this helps you out.

            Viewing 3 reply threads
            • The forum ‘Tcl Library’ is closed to new topics and replies.