Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to: Double space a memo field on a report 1

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB
Hi all

When I print a report, is there any way to get the memo field on the report to double space?

(Version 6 or 9)

Many thanks

Lee


Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Code:
x=[ABC]+CHR(13)+CHR(10)+[XYZ]
?x
?STRTRAN(x,CHR(13)+CHR(10),CHR(13)+CHR(10)+CHR(13)+CHR(10))

Brian
 
It's possible for a memo field to contain data with no CHR(13)+CHR(10).

Can't say what new feature may be in VFP 9, but with VFP6, if you can't get by with using a different font, you may have to parse the memo field and either add extra line feeds or put them in a cursor or table and use that data as in a child relationship.


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
DSummZZZ

Any suggestions on which font?

baltman

I see that produces:

ABC
XYZ
ABC

XYZ

I tried the following:
Code:
CLEAR
USE MYTABLE
GO 2
x=TRIM(MYFIELD)+CHR(13)+CHR(10) && MEMO FIELD
?x
?STRTRAN(x,CHR(13)+CHR(10),CHR(13)+CHR(10)+CHR(13)+CHR(10))
This doesn't work on screen so am I missing something?

Also how would I apply this to a report and get the MEMO field to double space?

Thank you both for posting

Lee

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Hi Lee,

First choose a number of characters you'd like in each line. Then instead of printing the memo field itself print the results of a function such as the one below.


FUNCTION dublspace && assumes line length of 20 chars
retval = ''
FOR i = 1 TO LEN(mytable.mymemo) STEP 20
retval = retval + SUBSTR(mytable.mymemo, i, 20) + CHR(13) + CHR(13)
ENDFOR
RETURN retval

Jim
 
Hi Jim

That sounds good, but how would I include the code you've posted on the report? There are many other fields on the same report from one table.

Thank you

Lee

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Hi Lee,

If the report is being called from a .prg then just put the function in the calling program and the report will find it.

If it's being called from a form, create dublspace as a method of the form. In the report print THISFORM.dublspace().

The other fields on the report are not affected by this at all.

Jim
 
Hi Jim

I know this thread is old but in the good spirit of posting replies, this one passed me by.

I've now had a chance to try it out and it doesn't seem to be working which I'm guessing I'm doing something wrong:

I have a table called TEST with just two fields to try it out, one of which is a memo field called HTMLBODY.

I tried this:
Code:
USE TEST
GO 1

DO DUBLSPACE

REPORT FORM TEST ;
  PREVIEW FOR RECNO()=1

CLEAR
RETURN

FUNCTION dublspace   &&  assumes line length of 20 chars
retval = ''
FOR i = 1 TO LEN(htmlbody) STEP 20
  retval = retval + SUBSTR(htmlbody, i, 20) + ;
  CHR(13) + CHR(13)
ENDFOR
RETURN retval
When the report is previewed it doesn't show the text double spaced.

The field on the report is set to stretch with overflow

Any ideas?

This APP is Version 9

Many thanks
Lee

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Hi Lee,

1. Omit the statement DO DUBLSPACE

2. In your report rather than print htmlbody, print DUBLSPACE(htmlbody)

Hope this helps.

Jim
 
Hi Jim

Thanks for the reply. I made the changes but an error appeared:
Code:
No parameter statement is found
with retval="" highlighted

Where does retval go?

Lee


Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Hi Lee,

The dublspace function does need a parameter statement. It could look something like the following:


FUNCTION dublspace && assumes line length of 20 chars
LPARAMETER mymemo
retval = ''
FOR i = 1 TO LEN(mymemo) STEP 20
retval = retval + SUBSTR(mymemo, i, 20) + ;
CHR(13) + CHR(13)
ENDFOR
RETURN retval


Retval is returned as the value of DUBLSPACE(htmlbody).

Jim
 
Hi Jim

ok, that works great (as expected) but one small problem now with the layout. I've tried different combinations, fonts and memo widths but the text repeats itself when it drops down to the next line. Here is an example:

memotext.jpg


Any suggestion?

Thank you Jim

Lee

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Hi Lee,

What exactly are you printing on your report? Is it the memo field from 1 record or multiple records? What are the contents of the field? Are you using "stretch with overflow?"

Jim
 
Hi Jim

What exactly are you printing on your report?
There will be a few variables from a table but these are placed in the page header and page footer.
Is it the memo field from 1 record or multiple records?
It is a memo field from 1 record (the example text is just replicated in a memo fields for test purposes). It is a single record on each page.
What are the contents of the field?
Purely text, sometimes a few lines, others many.
Are you using "stretch with overflow?"
Yes. As mentioned previously I have set the memo field to stretch with overflow.

Many thanks Jim

Lee

Visual FoxPro Versions: 6 & 9
Operating System: Windows XP
 
Hi Lee,

Sorry, I can't seem to be able to duplicate the behavior you're getting. I'm stumped.

Jim
 
Hi Lee,

Thanks for the link. In your code you have:

SUBSTR(htmlbody, i, 80)

Given a line length of 20 it should be:

SUBSTR(htmlbody, i, 20)

I think that will solve the problem.


Jim
 
Probably a better way to go is to use MLINE() rather than SUBSTR() to avoid words getting separated in the middle:

FUNCTION dublspace
LPARAMETER mymemo
retval = ''
FOR i = 1 TO MEMLINES(mymemo)
retval = retval + MLINE(mymemo, i) + ;
CHR(13) + CHR(13)
ENDFOR
RETURN retval


Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top