Strip units in OBX-5

Clovertech Forums Cloverleaf Strip units in OBX-5

  • Creator
    Topic
  • #122384
    ohrhull
    Participant

      Hello, I’m attempting to strip out units of measurement in OBX-5 fields when I receive them from a vendor.  In many OBXs they are going to send a value such as “14.8 cm” or “147.0 grams” etc.  I would also like to move that unit of measurement into the OBX-6 field.

      I am planning to use a translation I already have built.  I know this can be done via xlateStr commands or tcl code within the COPY action.  I have tried both and keep getting tripped up with the syntax/formatting of it.  Does anyone have experience doing this in a simple manner lately?

    Viewing 1 reply thread
    • Author
      Replies
      • #122385
        Jim Kosloskey
        Participant

          I am assuming you want to strip out some text from the OBX-5 field and place that in OBX-6. I will assume by your example, the text can vary in length and content. If that is true, then you need some sort of ‘anchor’ I think.

          For example, if the text always began or ended with something you can count on, or the following text always began a certain way, or there are a predictable number of spaces, or it starts the text for a specific length. That knowledge will help construct a reliable solution.

          BTW – shameful plug – I have a package that goes into a lot of detail regarding the STRING Action Functions and includes some additional functions I have written. You can have a copy if you email me (email in signature).

          email: jim.kosloskey@jim-kosloskey.com 30+ years Cloverleaf, 61 years IT – old fart.

        • #122386
          Paul Bishop
          Participant

            Will the value in OBX-5 always be in “<measurement> <unit>” with space between the two?  Will there ever be a measurement with an embedded space?  What about a unit with an embedded space?  This is easily done if there are no spaces in the measurement.  use the lindex command to pull parts out.  TCL snippet:

            lassign xlateInVals in_obx_5
            set out_obx_5 [lindex $in_obx_5 0]
            set out_obx_6 [lindex $in_obx_5 1]
            set xlateOutVals

              Your source would be the OBX-5.0 field and your destination would be both the OBX-5.0 field and OBX-6.0 field (or variables if you’d like) – just make sure both are listed since you’re outputting two values.

              If there are spaces in the units value, the second lindex would be changed to a lrange: “lrange $in_obx_5 1 end”

              This is just one way to do it – I’m sure others will come up with different solutions.

              Paul Bishop
              Carle Foundation Hospital
              Urbana, IL

          Viewing 1 reply thread
          • You must be logged in to reply to this topic.