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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP 6.0: Reports: Line spacing in multi-line fields 1

Status
Not open for further replies.

Kimed

Programmer
May 25, 2005
104
LT
Hi,

In my app, I have to print certain reports on standard forms. Some fields on those forms don't fit in a single line, so they have to be divided. The problem is that when I spread the field in report to occupy several lines, they don't fit into prefabricated blanks, making the report look messy. I only can change the line spacing by increasing font size, and that spoils the report in another way, not to mention that in such case field's *value* may not fit the blank. I might divide it to separate fields, to print SUBSTR(field,1,20),SUBSTR(field,21,40), etc. on each own separately positioned line, but then it's likely to be divided mid-word. So I'd also have to manually program a "smart" carry-over function - a task that VFP does for multi-line fields automatically. Or, God forbid, hyphenation. Which I'd rather avoid if possible. Is there any other way?

Thanks.
 
Kimed,

There should be no difficulty in placing an ordinary field in the report, increasing its height to accommodate the required number of lines, and specifying the relevant table field as the expression. VFP will handle the wordwrap for you, and no special action is needed on your part.

This has been a feature of the VFP report writer since it first came out (and of @/SAY before that).

Apologies if I've misunderstood the problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike's suggestion would be the preferred approach.

But an alternative to that if for you to intentionally break the data prior to submitting it to the report.

If you have a field which might over-flow, you could create your report's data table with that field broken into 2 separate fields. Each with an anticipated field length.

Then you would 'push' the excess data into the 2nd field of the table PRIOR to submitting it to the Report.

Within the report you place each Text box where you want it and then use the Print When... expression as !EMPTY(Field2) to control the printing of the 2nd Report Text box.

In that way you know when and where the over-flow data will appear.

Good Luck,
JRB-Bldr
 
Yes, I do increase the height of the field. The problem is the distance between lines *in* such a field. That's the problem, because I can't print the whole form as I'd like to, but must fit into preprinted blanks, which also define vertical spacing.
 

Did you try to play with different fonts and font sizes?
Not sure it would help, though, but worth a try.
 
Kimed,

No, I don't think you can vary the spacing between lines in a report field -- or, for that matter, anywhere in native VFP controls. The only thing I can suggest is that you find an ActiveX control that supports rich text.

I'm still not sure why you want to do this. Is it because your text must exactly fill some pre-defined space? To match an existing paper document, perhaps?

If that's so, and you decide you do need to split the text into multiple fields, then you'll have to write your own wordwrap routine. You can do that by using GETWORDCOUNT() and GETWORDNUM() to extract the words (if your version of VFP doesn't have those functions, you'll find them in FoxTools).

Build up each sub-field word by word, until the total with of the text approaches the width of the field. Use FONTMETRIC() and TXTWIDTH() for that. Bit tricky, but should be do-able.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
You can take advantage of the text-processing features of memo fields.

CREATE CURSOR mycursor (mymemo M(4))
APPEND BLANK
REPLACE mymemo WITH myfield
SET MEMOWIDTH TO 20 && or whatever
line1 = MEMLINE(1)
line2 = MEMLINE(2)
line3 = MEMLINE(3)

You can now print fields line1, line2, line3


Jim
 
Jim,

You can take advantage of the text-processing features of memo fields.

This is a much better solution than mine.

Kimed needs to keep in mind that the line width (as defined by SET MEMOWIDTH) is specified in characters rather than pixels, inches or whatever. That might be limitation if trying to fit a string of text into a pre-defined space.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Just my two cents and I don't know if this will work in your case. I have hacked the FRX and changed the height of memo and other fields to reduce the white space between lines. Here are the comments from my code.

* These are approx hgt to use for compressing the white space between lines on a report for a memo field
* They can also be used for regular fields
* They are recalculated by foxpro when the report is saved????
* Note: These values will be reset if you move the control or perform other editing of the report.
* Therefore, these changes should be the last thing you change on the report.

* Font Org Size New Size
* 8 1666.667 1250.000
* 9 1770.833 1328.125
* 10 1875.000 1354.167
* 11 1979.167 1458.333
* 12 2083.333 1562.500

You may have to play with these numbers a bit, but they seem to work for me. Work from the top of your report down the page when making changes to avoid the automatic reset by foxpro as you move things around.



Auguy
Northwest Ohio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top