[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Wrapping of a substring



Christy,

Tony is right.  Rather than working to a fixed line length (such as 28) you should use that only as a starting point, then work back looking for a blank.  Pseudo-code:
  Pos=28
  while substr(comments$,Pos,1)<>' '
    Pos=Pos-1
  end while
  print substr(comments$,1,Pos-1)    (,30)
  Comments$=substr(Comments$,Pos+1)
  Pos=50
  while ...

Wayne Ivory
Information Services
Westralian Sands Limited


>>> TD <tdelia@EROLS.COM> 17/10/98 10:35:33 am >>>
Christy,

   You stated the only problem is with the first line. You won't ever
get a
break because you're printing exactly 28 characters from the substring
and
the WRAP parameter is set to 28 characters. The WRAP command doesn't
understand
English - it understands there are 28 characters that logically fit in
the
space defined. You'll have to evaluate the first 28 characters - backup
to
the last embedded whitespace (blank) and concatenate the remainder of
the
intitial 28 with the $comments_2002 string... then continue with your
remaining lines... You should change you're substring logic to produce
the
2 strings...
                                                     -Tony DeLia


Christy_Zigich wrote:
>
> Hello to all!  I hope that someone can be of some assistance.   I am writing
> an SQR to create a print, my code to print the variable $comments_2000 is as
> follows:
>
> let $COMMENTS_20001 = substr($COMMENTS_2000,1,28)
> let $COMMENTS_20002 = substr($COMMENTS_2000,29,250)
>
> graphic () font 3 8
> let #pos = 30
> print $COMMENTS_20001 (#line, #pos) wrap 28 1 STRIP=<13> ON=<10>
>    let #length = #comments_2000_length - 28
>    if #length > 0
>    add 1 to #line
>    let #pos = 13
>
>    print $COMMENTS_20002 (#line, #pos) wrap 55 5  STRIP=<13> ON=<10>
>    end-if
>
>      if #length < 55
>         add 1 to #line
>      else
>
>         if #length < 110
>            add 2 to #line
>         else
>
>            if #length < 165
>               add 3 to #line
>            else
>
>               if #length < 210
>                  add 4 to #line
>               else
>
>                  if #length < 222
>                     add 5 to #line
>                  end-if
>               end-if
>            end-if
>         end-if
>      end-if
>
>  do chart-field-acct
> let #pos = 2
> print 'CHART FIELD ACCOUNT:'   (#line, #pos)
> print $chart_acct              (#line, 15 )
>
> add 1 to #line
> end-procedure  !Print-Line-Comments
>
> The client wants the first line of the comment to start at position 30 and
> then wrap to the next line starting at position 13.
>
> All of this works, my problem is that the output comments are wrapping in
> the middle of words
>
> Example:
>                                                 (#pos 30) Enter any comments that pert      <-- the problem
>              (#pos 13)  ain to Line 1 here.  These comments pertain to Line
> 1.  These
>                              comments will print on the PO.  The only time
> there seems to be a
>                              problem is on the first line: the
> $COMMENTS_20001 substr line.
>
>   Also, I have no embedded carriage returns.
>
> Thanks for your time,
> Christy Zigich
>
> Christy_Zigich@the-firm.net