PrintText PowerScript function
Description
Prints a single line of text starting at the specified coordinates.
Syntax
|
1 |
<span>PrintText</span> ( <span>printjobnumber</span>, <span>string</span>, <span>x</span>, <span>y</span> {, <span>fontnumber</span> } ) |
|
Argument |
Description |
|---|---|
|
printjobnumber |
The number the PrintOpen function |
|
string |
A string whose value is the text you |
|
x |
An integer specifying the x coordinate |
|
y |
An integer specifying the y coordinate |
|
fontnumber (optional) |
The number (1 to 8) of a font defined |
Return Values
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):
|
1 |
long Job |
|
1 |
|
1 |
// Define a new blank page. |
|
1 |
Job = PrintOpen() |
|
1 |
|
1 |
// Print the text. |
|
1 |
<span>PrintText</span>(Job,"PowerBuilder", 3700, 10) |
|
1 |
... // Other printing |
|
1 |
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:
|
1 |
long Job |
|
1 |
|
1 |
// Start a new job and a new page. |
|
1 |
Job = PrintOpen() |
|
1 |
|
1 |
// Define the font. |
|
1 |
PrintDefineFont(Job, 3, & |
|
1 |
   "Courier 10Cps", 250,700, & |
|
1 |
      Default!, AnyFont!, FALSE, FALSE) |
|
1 |
|
1 |
// Print the text. |
|
1 |
<span>PrintText</span>(Job, "Confidential", 3700, 10, 3) |
|
1 |
... // Other printing |
|
1 |
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:
|
1 |
long Job |
|
1 |
|
1 |
// Start a new job and a new page. |
|
1 |
Job = PrintOpen() |
|
1 |
|
1 |
// Print the text. |
|
1 |
x = <span>PrintText</span>(Job,"The material ", 2000, 4000) |
|
1 |
Print(Job, x, " in this report") |
|
1 |
Print(Job, 2000, "is confidential and should not") |
|
1 |
Print(Job, 2000, "be disclosed to anyone who") |
|
1 |
Print(Job, 2000, "is not at this meeting.") |
|
1 |
... // Other printing |
|
1 |
PrintClose(Job) |