Slit Long OB.5 into Multiple OBX segment with fixed OBX.5 lenth

Homepage Clovertech Forums Cloverleaf Slit Long OB.5 into Multiple OBX segment with fixed OBX.5 lenth

Tagged: 

  • Creator
    Topic
  • #120222
    HoedjeRo
    Participant

    Hi,

    I have a long OBX.5 value and I want to convert the OBX.5 value into multiple OBX segment where the length of OBX.5 can be no greater the 60 chars. Ideally you want to split on the last space before the next 60th character. I have done some TCL scripting for this but I don’t quite get what I want yet. I don’t think we can do this in a XLATE on it’s own but if possible that would be best. Does anyone have (partial) examples of how to accomplish this?

    Thanks, Roland

Viewing 5 reply threads
  • Author
    Replies
    • #120223
      Jim Kosloskey
      Participant

      I do not think there is anything native in Xlate to do the split portion. So you will need Tcl do do that specialized split.

      You could have the result of that split be a list then use ITERATE (either list or user type depending on your release level of Cloverleaf) to actually build the OBX segments from the list entries.

      I suspect the issue is the receiving system wants to display OBX-5 but has a 60 character line limit. In my opinion this is a failing of their software and they should make the appropriate accommodations.

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

    • #120230
      Gene Millard
      Participant

      Here is the tcl I use to change a NTE segment where NTE-3 is longer than 120 to multiple NTEs.

       

      Gene Millard

      The Guthrie Clinic

      • This reply was modified 1 year, 8 months ago by Gene Millard.
      Attachments:
      You must be logged in to view attached files.

      The Guthrie Clinic
      Sayre, PA

    • #120234
      Paul Bishop
      Participant

      There is a package of text utilities that I have used to split a line into specific lengths.  At the top of your proc, include the line “package require textutil”, then the function “textutil::adjust” will split the line to the specified length, returning the lines in a list separated by a line feed.  In the tcl proc we use it in, I have the command:

      set split_OBX5_list [split [textutil::adjust $obx5 -full 1 -length $max_length] \n]

      where $obx5 is the original value in obx-5 from the message and $max_length is the maximum length each line can be on the returned value.  The value placed in split_OBX5_list is the returned value split by the carriage return.  You can then loop through split_OBX5_list and create the new OBX lines.

      If you search for “tcl textutil” you can find the full help text of all the package procedures and options for textutil.

      Paul Bishop
      Carle Foundation Hospital
      Urbana, IL

    • #120235
      HoedjeRo
      Participant

      That has worked nicely. Thank you

    • #120236
      Jim Kosloskey
      Participant

      Paul,

      So where is that package located?

      Good info to know.

      Thanks

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

    • #120237
      Jim Kosloskey
      Participant

      Never mind – I see it is part of the Tcl distribution.

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

Viewing 5 reply threads
  • You must be logged in to reply to this topic.

Forum Statistics

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