Modify PID3.

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Modify PID3.

  • Creator
    Topic
  • #52968
    Robert Denny
    Participant

      I need a proc that will strip off the first four characters of a 10 character string and then insert an hyphen within every two characters of the remaining string.

      Here is the input MG00097667

      Here is the output 09-76-67

      The commands to do it within a translate would be most helpful.

    Viewing 3 reply threads
    • Author
      Replies
      • #76104
        Jim Kosloskey
        Participant

          Robert,

          We have a proc that extracts however many characters desired from a source.

          So in our case we woul:

          extract the number of characters needed from Pid-3 using proc (COPY Action)putting result in @temp (or whatever temp variable we want).

          extract the first 2 characters from temp using proc (COPY Action) putting those 2 characters in @temp1

          extract the next 2 characters from temp using proc (COPY Action) putting those 2 characters in @temp2

          extract the next 2 characters from temp using proc (COPY Action) putting those 2 characters in @temp3

          Then use the CONCAT Action with @temp1, @temp2, @temp3 and a separator of ‘-‘.

          One proc used multiple times and the aggragating of the procs functionality using the builtin Xlate capability.

          email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

        • #76105
          Robert Denny
          Participant

            Thanks Jim, I hadn’t thought about using the commands in xlate.

            good idea.

          • #76106
            Eric Fortenberry
            Participant

              You can also do this in one COPY by using a regular expression in the Pre Proc.  See below…


              set xlateOutVals {}

              foreach value $xlateInVals {

              lappend xlateOutVals [regsub -all {(.{2})(?=.)} [string range $value 4 end] {1-}]

              }

            • #76107
              Keith McLeod
              Participant

                Could also do this without the loop.

                hcitcl>set x MG00097667

                MG00097667

                hcitcl>regsub — {.{4}(d{2})(d{2})(d{2})} $x {1-2-3} y

                1

                hcitcl>echo $y

                09-76-67

                hcitcl>

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