PrintText

Description

Prints a single line of text starting at the specified coordinates.

Syntax

PrintText ( printjobnumber, string, x, y {, fontnumber } )

Argument

Description

printjobnumber

The number the PrintOpen function assigned to the print job.

string

A string whose value is the text you want to print.

x

An integer specifying the x coordinate in thousandths of an inch of the beginning of the text.

y

An integer specifying the y coordinate in thousandths of an inch of the beginning of the text.

fontnumber (optional)

The number (1 to 8) of a font defined for the job by using the PrintDefineFont function or 0 (the default font for the printer). If you omit fontnumber, the text prints in the current font for the print job.


Return value

Integer. Returns the x coordinate of the new cursor location (that is, the value of the parameter x plus the width of the text) if it succeeds. PrintText returns -1 if an error occurs. If any argument's value is null, PrintText returns null.

Usage

PrintText does change the position of the print cursor, unlike the other print functions for which you specify coordinates. The print cursor moves to the end of the printed text. PrintText also returns the x coordinate of the print cursor. You can use the return value to determine where to begin printing additional text.

PrintText does not change the print cursor's y coordinate, which is its vertical position on the page.

Examples

These statements start a new print job and then print PowerBuilder in the current font 3.7 inches from the left edge at the top of the page (location 3700,10):

long Job
 
// Define a new blank page.
Job = PrintOpen()
 
// Print the text.
PrintText(Job,"PowerBuilder", 3700, 10)
... // Other printing
PrintClose(Job)

The following statements define a new blank page and then print Confidential in bold (as defined for font number 3), centered at the top of the page:

long Job
 
// Start a new job and a new page.
Job = PrintOpen()
 
// Define the font.
PrintDefineFont(Job, 3, &
   "Courier 10Cps", 250,700, &
      Default!, AnyFont!, FALSE, FALSE)
 
// Print the text.
PrintText(Job, "Confidential", 3700, 10, 3)
... // Other printing
PrintClose(Job)

This example prints four lines of text in the middle of the page. The coordinates for PrintText establish a new vertical position for the print cursor, which the subsequent Print functions use and increment. The first Print function uses the x coordinate returned by PrintText to continue the first line. The rest of the Print functions print additional lines of text, after tabbing to the x coordinate used initially by PrintText. In this example, each Print function increments the y coordinate so that the following Print function starts a new line:

long Job
 
// Start a new job and a new page.
Job = PrintOpen()
 
// Print the text.
x =  PrintText(Job,"The material ", 2000, 4000)
Print(Job, x, " in this report")
Print(Job, 2000, "is confidential and should not")
Print(Job, 2000, "be disclosed to anyone who")
Print(Job, 2000, "is not at this meeting.")
... // Other printing
PrintClose(Job)

See also

Print

PrintClose

PrintOpen