Reply To: OBX length is 80 char but rec app wraps at 78 chars

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf OBX length is 80 char but rec app wraps at 78 chars Reply To: OBX length is 80 char but rec app wraps at 78 chars

#58956
Tom Patton
Participant

    Here is a snippet of code.

    This code gathered up multiple OBX:5 strings which might have had the repeat (~) char embedded.  At the end of each append, it placed another ~ so you get something like this in $fullReport:

    text line~ text line text line text line~text line~ etc. some text lines being way longer than the allowable -75 chars in our case.

    This snippet will split $fullReport on the ~ and then evaluate the length of each list item.  If it’s longer than 74 chars, then the list item is broken up into 74 byte (or less to get whole word) chunks placing them into $newOBX5.

    Hopefully you can pull somthing out of this that you might use.

                 #  


                  #  now create the OBX segment

                  #  LCR can only handle 74 characters, so break up any

                  #  lines larger than this.

                  #


                  set res_split [split $fullReport “~”]

                  set newOBX5 “”

                  foreach resline $res_split {

                      #  echo resline $resline

                      set reslinelen [clength $resline]

                      if {$reslinelen < 76} {

                          append newOBX5 “~” $resline

                      } else {

                          set begofstr 0

                          set endofstr 74

                          set savlinelen $reslinelen

                          while {$reslinelen > 76} {

                              # locate the begining of the word the string land on

                              # subtract 1 to get to the space before

                              set endofstr [expr [string wordstart $resline $endofstr] – 1]

                              #echo “next line” [string trim [crange $resline $begofstr $endofstr]]

                              # trim the text to left justify the line

                              append newOBX5 “~” [string trim [crange $resline $begofstr $endofstr]]

                              #  echo newOBX5 $newOBX5

                              # now get the difference between begining and end of string

                              # so we can piece out the lines in the paragraph

                              set diff [expr $endofstr – $begofstr]

                              # add a char so the same char isnt repeated

                              incr begofstr [expr $diff + 1]

                              incr endofstr  75

                              set reslinelen [expr $reslinelen – $diff]

                              # echo reslinelen $reslinelen

                              # echo begofstr $begofstr

                              # echo endofstr $endofstr

                              # echo savlinelen $savlinelen

                          }

                          ## get the last one

                          append newOBX5 “~” [crange $resline $begofstr $savlinelen]

                       }