Printing a memo field with out extra blanks 
Author Message
 Printing a memo field with out extra blanks

I am using a sql select statement to retreive data from several tables.  At
least one field is a memo field were memo field may multiple lines where some
of the lines have leading and trailing blanks and even worse blank lines
embed in it.  What I need to do is trim leading and trail blanks and remove
blank lines so that what gets print in the report looks like one long line.
For example (using an _ to denote blanks unwanted blanks)  the memo field

        ____this is the first line_______
        __
        __this is the third line_

get printed as

        this is the first line this is the third line

Can I do this?  If so how?  Oblivoulsy an efficent method would be preferred.

TIA.



Sat, 21 Sep 2002 03:00:00 GMT  
 Printing a memo field with out extra blanks
Write your own function (or copy this one):

PROCEDURE {*filter*}
LPARAMETER cMemo
LOCAL i, cRetVal
cRetVal = ""
FOR i = 1 TO MEMLINES( cMemo )
   IF NOT EMPTY( ALLTRIM( MLINE( cMemo, i ) ) )
      cRetVal = cRetVal + " " + ALLTRIM( MLINE( cMemo, i ) )
   ENDIF  
ENDFOR

RETURN cRetVal

Then use it in the select, like:

   SELECT {*filter*}( memofield ) AS stripped FROM ...

- John


Quote:

>I am using a sql select statement to retreive data from several tables.  At
>least one field is a memo field were memo field may multiple lines where some
>of the lines have leading and trailing blanks and even worse blank lines
>embed in it.  What I need to do is trim leading and trail blanks and remove
>blank lines so that what gets print in the report looks like one long line.
>For example (using an _ to denote blanks unwanted blanks)  the memo field

>    ____this is the first line_______
>    __
>    __this is the third line_

>get printed as

>    this is the first line this is the third line

>Can I do this?  If so how?  Oblivoulsy an efficent method would be preferred.

>TIA.

--
Free Email, Usenet, and $1000 Giveaway -- http://www.*-*-*.com/


Sat, 21 Sep 2002 03:00:00 GMT  
 Printing a memo field with out extra blanks

Quote:

>I am using a sql select statement to retreive data from several tables.  At
>least one field is a memo field were memo field may multiple lines where some
>of the lines have leading and trailing blanks and even worse blank lines
>embed in it.  What I need to do is trim leading and trail blanks and remove
>blank lines so that what gets print in the report looks like one long line.
>For example (using an _ to denote blanks unwanted blanks)  the memo field

>    ____this is the first line_______
>    __
>    __this is the third line_

>get printed as

>    this is the first line this is the third line

>Can I do this?  If so how?  Oblivoulsy an efficent method would be preferred.

     I wrote some code to clean up data in this manner.  You could
adapt my code.  I don't know how efficient it is as my concern was
something that worked.  My editbox subclass uses this code.

     Minspacing means to replace strings of spaces internal to a line
with just one space. e.g.
          "   ABC   DEF   "
is minspaced to
          "   ABC DEF   "

********** Start of Included Code **********
* bffmtmemo
* Basic Formatting Formatting Procedure for Memo Fields
* Last Modification: 99-08-09
*
*      Individual lines are automatically rtrimmed regardless of the
values
* of fltrim and fminspace.  fminspace is taken to mean to delete blank
lines
* at the start, middle, and end.  Trailing blank lines will be deleted
* regardless of the value of fminspace.

procedure bffmtmemo
lparameters thefield, fupper, fltrim, fminspace

   local buildmemo, numlines, first, i, workline

   buildmemo=""

   numlines=memlines(thefield)
   _mline=0
   first=.t.

   for i=1 to numlines

      workline=mline(thefield,1,_mline)
      workline=rtrim(workline)

      if fltrim
         workline=ltrim(workline)
         endif

      if fminspace and len(workline)=0
         loop
         endif

      if fminspace
         workline=bffmtminsp(workline,fltrim)
         endif

      if fupper
         workline=upper(workline)
         endif

      if first
         first=.f.
      else
         buildmemo=buildmemo+chrcr
         endif
      buildmemo=buildmemo+workline

      endfor

   return buildmemo

   endproc

* bffmtminsp
* Minspace a LINE
* Last Modification: 99-08-09

procedure bffmtminsp
lparameters theline, fltrim

   local workline, buildline, fprevspace, length, i, currchar

   workline=ltrim(theline)
   if fltrim
      ltrimamt=0
   else
      ltrimamt=len(theline)-len(workline)
      endif

   if "  "$workline
      buildline=""
      fprevspace=.f.
      length=len(workline)
      for i=1 to length
         currchar=substr(workline,i,1)
         if currchar#" "
            if fprevspace
               buildline=buildline+" "
               fprevspace=.f.
               endif
            buildline=buildline+currchar
         else
            fprevspace=.t.
            endif
         endfor
      workline=buildline
      endif

   workline=space(ltrimamt)+workline

   return workline

   endproc
********** End of Included Code **********

Quote:
>TIA.

     You're welcome.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
     I have preferences.
     You have biases.
     He/She has prejudices.



Sat, 21 Sep 2002 03:00:00 GMT  
 Printing a memo field with out extra blanks

Quote:



Thanks to those who replied.


Sun, 22 Sep 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Help: Report Form Fields print blank - reposted report form fields print blank report form fields print blank

2. Trimming extra returns of a memo field

3. FPW2.6 - printing & print preview - memo fields

4. Boxes in Print Outs

5. Boxes in Print Outs

6. FP2.6 Win Boxes in Print outs

7. Total command includes 'extra' fields

8. extra 0's in input fields

9. Printing a Memo Field

10. Printing Large Memo Fields (Bombing)

11. Printing long memo fields in FPMac

12. Printing memo field from report form

 

 
Powered by phpBB® Forum Software