Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

Print

This method lets you put text on a form (or the main Visual FoxPro window).

Usage

frmForm.Print( [ cTextToDisplay [ nHorizPos, nVertPos ] ] )

The specified text is displayed on the form at the position of CurrentX and CurrentY using the form’s ForeColor and Font settings. CurrentX and CurrentY are updated to the end of the string. If cTextToDisplay is omitted, CurrentY increases by the height of a line in the form’s font.

The undocumented nHorizPos and nVertPos parameters let you decide where to put the string in VFP 6. They respect ScaleMode, so you can use either pixels or rows and columns.

Can you have a bug for an undocumented feature? We think so.

Although you can omit either of these parameters, the position of the string when you do is pretty strange. Sometimes, the CurrentX and/or CurrentY values seem to be used. At others, it appears that 0 is used. Yet, other times, it looks like the one value you pass is used for both parameters. Bottom line, either pass both or neither. It's not worth the aggravation to omit one.

You can give Print multi-line strings, but they’re pretty badly behaved. The second and subsequent lines start at the left-hand edge of the form, regardless of the initial position of CurrentX. The help is either misleading or wrong (hard to tell which) about how multi-line strings affect CurrentX and CurrentY, too. As with single-line strings, CurrentX and CurrentY end up at the ending position of the string.

Strings that don’t fit on the form wrap to the next line, kind of like multi-line strings.

On the whole, we’d say to stay away from Print, except for carefully controlled special cases.

Example

_SCREEN.CLS()
_SCREEN.Print("This is a test. ")
_SCREEN.Print("This is only a test.")
_SCREEN.Print()
_SCREEN.CurrentX=200
* The next line will print "Here's a multi-line string" starting
* at position 200, then put "See what happens" at the left-hand
* edge of the next line.
_SCREEN.Print("Here's a multi-line string"+chr(13)+;
              "See what happens")
* Try the undocumented position parameters
_SCREEN.Print("I'll position this where I want it",200,475)

See Also

Cls, CurrentX, CurrentY, ForeColor, FontBold, FontItalic, FontName, FontSize, FontStrikeThru, FontUnderline, ScaleMode