TCl testing error

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCl testing error

  • Creator
    Topic
  • #48852
    Mark Perschbacher
    Participant

      I am trying to write a proc to string map all the ~’s in the xlate output to blank spaces, and am getting this error when running it through the Testing function

      sourceFilter D:/quovadx/qdx5.3/integrator/test/tclprocs/ptrim.tcl: Failed to source filtered file: extra characters after close-brace

      [0:TEST] Tcl error:

      msgId = message0

      proc = ‘ptrim’

      args = ”

      result = ‘invalid command name “ptrim”‘

      errorInfo: ‘

      invalid command name “ptrim”    while executing

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

      Here is the proc.  I would appreciate any of you tcl pros taking a look.

      proc ptrim {args} {

      keylget args MODE mode

      switch -exact–$mode {

      run {

      keylget args MSGID mh

      set msg [msgget $mh]

      set segs [split $msg r]

      set msg “”

      set obxloc [lsearch -regexp $segs “^OBX”]

      set obxseg [lindex $segs $obxloc]

      set obxtxt [lindex [split $obxseg|] 5]

      set obxtxt1 [lindex [split $obxseg|] 1]

      set obxtxt2 [lindex [split $obxseg|] 2]

      set obxtxt3 [lindex [split $obxseg|] 3]

      set obxtxt4 [lindex [split $obxseg|] 4]

      set obx_flds “$[obxtxt1}|$[obxtxt2}|$[obxtxt3}|$[obxtxt4}”

      set obx_cnt 1

      set obx_out “”

      foreach obxsg {

      [string map “~ { }” $obxtxt] {continue}

      append obx_out “OBX|${obx_cnt}|${obx_flds}|${obxsg}r”

      incr obx_cnt

      return “{CONTINUE $mh

      }”

      set new_msg [lreplace $segs $obxloc $obxloc $obx_out]

      msgset $mh [join $new_msg r]

      }

    Viewing 10 reply threads
    • Author
      Replies
      • #59922
        David Barr
        Participant

          This is the error message you are getting:

             sourceFilter D:/quovadx/qdx5.3/integrator/test/tclprocs/ptrim.tcl: Failed to source filtered file: extra characters after close-brace

          I think this error might come from these lines in your proc:

          Code:

          return “{CONTINUE $mh
          }”

          These two lines should be combined into a single line.

          Additionally, it looks like you are missing close braces at the bottom of you code for you proc, switch statement, and “run” item.  You should probably think about using indentation in your program so that it is easier to see when you have missing braces.  It’s possible that your program is indented properly and the code isn’t being displayed through this forum.  It looks like every line is aligned on the left margin.  Normally, you would want to put extra space before items that are within braces.  For example, it is easier to read this:

          Code:

          proc hello { } {
           global debug
           if { $debug } {
             puts “debugging proc hello”
           }
           puts “Hello, world!”
          }

          than this:

          Code:

          proc hello { } {
          global debug
          if { $debug } {
          puts “debugging proc hello”
          }
          puts “Hello, world!”
          }

        • #59923
          Mark Perschbacher
          Participant

            The braces for switch and run are in the proc, I missed them when I cut and pasted it over, sorry.  I combined the Continue statement into one line, but still got the error.  Any other ideas?

          • #59924
            Scott Lee
            Participant

              I think there may be a few issues here, bu here is one thing I noticed right off…

              Code:

              set obx_flds “$[obxtxt1}|$[obxtxt2}|$[obxtxt3}|$[obxtxt4}”


              should be

              Code:

              set obx_flds “${obxtxt1}|${obxtxt2}|${obxtxt3}|${obxtxt4}”

              The error message definitely indicates that you don’t have all your ‘squirrely braces’ matched up

            • #59925
              Mark Perschbacher
              Participant

                Scott, yes the missing { were causing at least part of the error.  Good job hawkeying them out.  Thanks for taking a look.  As an aside, your  HG Wells signature is a classic.

              • #59926
                Scott Lee
                Participant

                  So is it working now?  Let us know if it’s not, and post the whole proc and we’ll dig a little deeper….

                  Thanks!

                  Scott

                • #59927
                  Mark Perschbacher
                  Participant

                    Scott, funny you should ask.  I am getting an incorrect syntax error on the foreach argument.  I copied a good amount of this from a proc listed on Clovertech, but there must still be some incorrect lines.

                    proc ptrim {args} {

                    keylget args MODE mode

                    switch -exact — $mode {

                    run {

                    keylget args MSGID mh

                    set msg [msgget $mh]

                    set segs [split $msg r]

                    set msg “”

                    set obxloc [lsearch -regexp $segs “^OBX”]

                    set obxseg [lindex $segs $obxloc]

                    set obxtxt [lindex [split $obxseg|] 4]

                    set obxtxt1 [lindex [split $obxseg|] 0]

                    set obxtxt2 [lindex [split $obxseg|] 1]

                    set obxtxt3 [lindex [split $obxseg|] 2]

                    set obxtxt4 [lindex [split $obxseg|] 3]

                    set obx_flds “${obxtxt1}|${obxtxt2}|${obxtxt3}|${obxtxt4}”

                    echo $obxtxt

                    set obx_cnt 1

                    set obx_out “”

                    foreach obxsg {

                    #echo $obxtxt

                    [string map “~ { }” $obxtxt] {continue}

                    append obx_out “OBX|${obx_cnt}|${obx_flds}|${obxsg}r”

                    incr obx_cnt

                    }

                    #return “{CONTINUE $mh}”

                    set new_msg [lreplace $segs $obxloc $obxloc $obx_out]

                    msgset $mh [join $new_msg r]

                    #echo $mh

                    }

                    }

                    }

                  • #59928
                    garry r fisher
                    Participant

                      Hi,

                      I thought the foreach needed two parameters i.e.

                      foreach item list {

                         # process each item

                      }

                      Hope this helps.

                      Garry

                    • #59929
                      Scott Lee
                      Participant

                        Not sure I follow the logic in you code so I can’t help much there, but maybe if we can get you past the syntax errors you’ll be able to work it out…

                        Code:

                        set obxtxt [lindex [split $obxseg|] 4]


                        should have a space before the pipe…

                        Code:

                        set obxtxt [lindex [split $obxseg |] 4]

                        And I don’t recognize this syntax, so I am not sure what you are trying to do…

                        Code:

                        [string map “~ { }” $obxtxt] {continue}


                        Do you want to assign the result of string map to a variable?  What does the {continue} do at the end?

                        Code:

                        set newobx [string map “~ { }” $obxtxt]

                        Scott

                      • #59930
                        Russ Ross
                        Participant

                          When you do eventually get your proc working and want to test it, you might like to know that the hcitester and the interface in the NetConfig may give confusingly different outcomes, especially when using funky characters as input arguments.

                          The easiest way for me to describe this behaivor is to ask you to read the notes section in the comment header of a proc I wrote to replace all occurences of one character with another.

                          tps_regsub_all.tcl

                          Code:

                          # Begin Module Header ==========================================================
                          #
                          # —–
                          # Name:
                          # —–
                          #
                          # tps_regsub_all.tcl
                          #
                          # ——–
                          # Purpose:
                          # ——–
                          #
                          # Use the regsub command to replace all occurrances of $expression_1 with $expression_2
                          # that occur in the entire message.
                          #
                          # ———–
                          # Input Args:
                          # ———–
                          #
                          # Args: tps keyedlist containing:
                          #
                          #       MODE    run mode (”start” or “run”)
                          #       MSGID   message handle
                          #       CONTEXT Should be sms_ib_data or sms_ob_data
                          #
                          #       ARGS.EXPRESS_1 = the expression that describes the charaters to be replaced
                          #       ARGS.EXPRESS_2 = the expression that describes the new replacement characters
                          #
                          # ———–
                          # Output Args:
                          # ———–
                          #
                          # Returns: tps keyed list containing dispositions
                          #
                          #     CONTINUE   The received message with the overwritten character.
                          #
                          # ——
                          # Notes:
                          # ——
                          #
                          # UPoC type = TPS
                          #
                          # When using hcitester enclose args in curly braces
                          # or use double escapes !!!
                          #
                          # When using hcinetconfig do not enclose args with curly barces
                          # or either enclose args in double quotes !!!
                          #
                          #
                          # Examples of Normal Usage via hcinetconfig:
                          # ——————————————
                          #
                          #    Proc :  tps_regsub_all
                          #    Args :  {COMMENT {change MS Word left smart quote to ASCII double quote}}
                          #            {EXPRESSION_1 x093}
                          #            {EXPRESSION_2 x022}
                          #
                          #    Proc :  tps_regsub_all
                          #    Args :  {COMMENT {change MS Word right smart quote to ASCII double quote}}
                          #            {EXPRESSION_1 x094}
                          #            {EXPRESSION_2 x022}
                          #
                          #    Proc :  tps_regsub_all
                          #    Args :  {COMMENT {change MS Word long dash to ASCII dash}}
                          #            {EXPRESSION_1 x096}
                          #            {EXPRESSION_2 x02d}
                          #
                          #
                          # Examples of Normal Usage via hcitester:
                          # —————————————
                          #
                          #    Proc :  tps_regsub_all
                          #    Args :  {COMMENT {change MS Word left smart quote to ASCII double quote}}
                          #            {EXPRESSION_1 {x093}}
                          #            {EXPRESSION_2 {x022}}
                          #
                          #    Proc :  tps_regsub_all
                          #    Args :  {COMMENT {change MS Word right smart quote to ASCII double quote}}
                          #            {EXPRESSION_1 {x094}}
                          #            {EXPRESSION_2 {x022}}
                          #
                          #    Proc :  tps_regsub_all
                          #    Args :  {COMMENT {change MS Word long dash to ASCII dash}}
                          #            {EXPRESSION_1 {x096}}
                          #            {EXPRESSION_2 {x02d}}
                          #
                          # More Examples of Normal Usage via hcitester:
                          # ——————————————–
                          #
                          #    Proc :  tps_regsub_all
                          #    Args :  {COMMENT {change MS Word left smart quote to ASCII double quote}}
                          #            {EXPRESSION_1 \x093}
                          #            {EXPRESSION_2 \x022}
                          #
                          #    Proc :  tps_regsub_all
                          #    Args :  {COMMENT {change MS Word right smart quote to ASCII double quote}}
                          #            {EXPRESSION_1 \x094}
                          #            {EXPRESSION_2 \x022}
                          #
                          #    Proc :  tps_regsub_all
                          #    Args :  {COMMENT {change MS Word long dash to ASCII dash}}
                          #            {EXPRESSION_1 \x096}
                          #            {EXPRESSION_2 \x02d}
                          #
                          #
                          # ——–
                          # History:
                          # ——–
                          #
                          # 2002.05.17 Russ Ross
                          #          – implemented initial version.
                          #
                          # 2002.05.20 Russ Ross
                          #          – added comments to point out that the hcitester and hcinetconfig
                          #            do not treat the input arguments the same; and gave examples
                          #            of how to pass the input args to both the hcitester and hcinetconfig
                          #
                          # End Module Header ============================================================

                          proc tps_regsub_all { args } {

                             keylget args MODE mode
                             global HciConnName
                             set module “tps_regsub_all”

                             switch -exact — $mode {

                                 start {
                                     return “”
                                 }

                                 run {
                                     keylget args MSGID mh
                                     keylget args CONTEXT ctx
                                     if {    [keylget args ARGS.EXPRESSION_1 expression_1]
                                          && [keylget args ARGS.EXPRESSION_2 expression_2] } {
                                         set msg [msgget $mh]
                                         set new_msg “”
                                         regsub -all $expression_1 $msg $expression_2 new_msg
                                         msgset $mh $new_msg
                                     }
                                     return “{CONTINUE $mh}”
                                 }

                                 shutdown {
                                     # Doing some clean-up work
                                 }

                                 default {
                                     echo “Unknown mode in $module: ‘$mode'”
                                     return “”
                                 }
                             }
                          }

                          Russ Ross
                          RussRoss318@gmail.com

                        • #59931
                          Mark Perschbacher
                          Participant

                            Thanks for your input.  I emailed Jim Kosoloskey with this, and he showed me how to accomplish this within the xlate.  I can pass along the config if you are interested.

                          • #59932
                            Russ Ross
                            Participant

                              Your offer to share is thoughtful but not necessary since I was able to convince MD Anderson Cancer Center to hire Jim Kosloskey seems like about 6 years ago.

                              Jim has proven to be an awsome addition to our integration team and I have direct access to his stuff and knowledge daily so no need to pass it along to me.

                              I think of Jim as a clovertech GOD and do not know how he finds the time to post/reply so much.

                              You might think he is on auto pilot and has tons of spare time but nothing could be further from the truth.

                              We stay very busy being the largest Cancer facilty in the world (8.5 million square feet altogether with over 15,000 employees last I heard) with over 800 interfaces currently.

                              Of course it is nowhere as bad as when I was the only integration engineer at MD Adnerson Cancer Center about 8 years ago, now that was torture.

                              Russ Ross
                              RussRoss318@gmail.com

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