TCL to remove 01 characters

Homepage Clovertech Forums Read Only Archives Cloverleaf Tcl Library TCL to remove 01 characters

  • Creator
    Topic
  • #53629
    Barbi
    Participant

    I need help removing the “01” from ORC-2.  

    ORC|CA|0000000101|||DC|N|1&ML^^^201304270005^^^0

    proc xltPlaceOrderNum {} {

       upvar xlateId       xlateId

     xlateInList   xlateInList

     xlateInTypes  xlateInTypes

     xlateInVals   xlateInVals

     xlateOutList  xlateOutList

     xlateOutTypes xlateOutTypes

     xlateOutVals  xlateOutVals

     

    set OrderNum [cequal [crange $xlateInVals 7] 7]

    set xlateOutVals $OrderNum

    }

    }

Viewing 3 reply threads
  • Author
    Replies
    • #78347
      Charlie Bursell
      Participant

      Which “01”  there are two of them.  Is it always in the same place?

    • #78348
      Barbi
      Participant

      Charlie

      thanks for your posting.  I was over thing it to much but I did forget out to be something like this

      set OrderNum [lindex $xlateInVals 0]

      set newOrderNum [string range $OrderNum 0 [expr [string length $OrderNum] – 3]]

      set xlateOutVals {}

      lappend xlateOutVals $newOrderNum

      this does do the job.  thanks again

    • #78349
      Charlie Bursell
      Participant

      A little too much work  ðŸ˜€

      set OrderNum [lindex $xlateInVals 0]

      set newOrderNum [string range $OrderNum 0 end-3]

      set xlateOutVals

        Or if you are into LEGO commands

        set xlateOutVals

          0 end-3]]

      • #78350
        Barbi
        Participant

        Cannot get it to look at OBR works good on PV1?

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

        # Name:        select_pv1_17_obr_16                                           #

        # Purpose: This proc determines if the message contains                           #

        # one of the Doctors in the table.                             #

        # If the message matches the criteria, it is passed;           #

        # ELSE the message is killed.                                  #

        # Table is entered as an argument.                             #

        #                                                                                 #

        # Written by:                                                        #

        #    Micro Star Inc.com                                                 #

        # Date:    05/01/2012                                                         #

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

        # # # # # # # # # # # # # # #  Changes  # # # # # # # # # # # # # # # # # # # # # #

        #                                                                                 #

        # Date Comments      Changed By                                   #

        #                                                                                 #

        # UPoC type: tps                                                          #

        # Args: tps keyedlist containing the following keys:                           #

        #       MODE    run mode (“start”, “run” or “time”)                            #

        #       MSGID   message handle                                                 #

        #       ARGS    none                                                           #

        #                                                                           #

        #                                                                                 #

        # Returns: tps disposition list:                                                  #

        #                                                #

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

        proc select_pv1_17_obr_16 { args } {

           keylget args MODE mode               ;# Fetch mode

           set dispList {}

           switch -exact — $mode {

               start {

                   # Perform special init functions

             }

               run {

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

        #          Hard Code                                                              #

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

                 set segment1 “PV1”

                 set segment2 “OBR”

        keylget args MSGID mh

        keylget args ARGS arg_tbl

           set msg [msgget $mh]

           set segmentList [split $msg “r”]

           set fieldSeparator [crange $msg 3 3]

           set subfieldSeparator [crange $msg 4 4]

           set DocTable $arg_tbl

               set header [lrange [split $msg “r”] 0 1]

               set msh [split [lindex $header 0] $fieldSeparator]

        foreach seg [split $msg “r”] {

        set segID [lindex [split $seg $fieldSeparator] 0]

          if { [cequal $segID “PV1”]} {

           #set ptclass [lindex [split $seg $fieldSeparator] 2]

           # set pttype [lindex [split $seg $fieldSeparator] 10]

                     set doctest_fld [lindex [split $seg $fieldSeparator] 17]

                     set doctest [lindex [split $doctest_fld $subfieldSeparator] 0]

           }

        }

             foreach seg [split $msg “r”] {

        set segID [lindex [split $seg $fieldSeparator] 0]

          if { [cequal $segID “OBR”]} {

                     set dr_number [lindex [split $seg $fieldSeparator] 16]

           }

        }

        echo docnums:$doctest

        echo segment1:$segment1

        echo segment2:$segment2

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

        # If doctor number matches one of the entries in the argument table               #

        #     set match to yes, so the pass flag will be set to Yes                       #

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

        set match “N”

                 set match [tbllookup $DocTable $doctest]

                 

                 if {[cequal $segment1 “PV1”]} {

        if {$match != “N”} {

              lappend dispList “CONTINUE $mh”

        echo PV1 CONTINE message:$mh

            } else {

                 if {[cequal $segment2 “OBR”]} {

        if {$match != “N”} {

              lappend dispList “CONTINUE $mh”

        echo OBR CONTINE message:$mh

            } else {

                lappend dispList “KILL $mh”

        echo OBR Kill message:$mh

        }

        }

                           }

        }

        echo mh:$mh

               

                  return $dispList

              }

              shutdown {

        }

           }

         }

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

    Forum Statistics

    Registered Users
    5,129
    Forums
    28
    Topics
    9,301
    Replies
    34,448
    Topic Tags
    288
    Empty Topic Tags
    10