PrintSend PowerScript function
Description
Sends an arbitrary string of characters to the printer. PrintSend is
usually used for sending escape sequences that change the printer’s
setup.
PrintSend is an obsolete function and is
provided for backward compatibility only. The ability to use this
function is dependent upon the printer driver.
Syntax
1 |
<span>PrintSend</span> ( <span>printjobnumber</span>, <span>string</span> {, <span>zerochar </span>} ) |
Argument |
Description |
---|---|
printjobnumber |
The number the PrintOpen function |
string |
A string you want to send to the printer. |
zerochar |
An ASCII value (1 to 255) that you want |
Return Values
Integer. Returns 1 if it succeeds and
-1 if an error occurs. If any argument’s value is null, PrintSend returns null.
Usage
Use PrintSend to send escape sequences
to specific printers (for example, to set condensed mode or to set
margins). Escape sequences are printer specific.
As with any string, the number zero terminates the string argument.
If the printer code you want to send includes a zero, you can use
another character for zero in string and specify
the character that represents zero in zerochar.
The character you select should be a character you do not usually
use. When PowerBuilder sends the string to the printer it converts
the substitute character to a zero.
A typical print job, in which you want to make printer-specific
settings, might consist of the following function calls:
-
PrintOpen
-
PrintSend, to change the printer
orientation, select a tray, and so on -
PrintDefineFont and PrintSetFont to
specify fonts for the job -
Print to output job text
-
PrintClose
Examples
This example opens a print job and sends an escape
sequence to a printer in IBM Proprinter mode to change the margins.
There is no need to designate a character to represent zero:
1 |
long Job |
1 |
1 |
// Open a print job. |
1 |
Job = PrintOpen() |
1 |
1 |
/* Send the escape sequence. |
1 |
1B is the escape character in hexadecimal. |
1 |
X indicates that you are changing the margins. |
1 |
030 sets the left margin to 30 character spaces. |
1 |
040 sets the right margin to 40 character spaces. |
1 |
*/ |
1 |
<span>PrintSend</span>(Job," <span>~</span> h1BX <span>~</span> 030 <span>~</span> 040") |
1 |
... // Print text or DataWindow |
1 |
1 |
// Send the job to the printer or spooler. |
1 |
PrintClose(Job) |
This example opens a print job and sends an escape
sequence to a printer in IBM Proprinter mode to change the margins.
The decimal ASCII code 255 represents zero:
1 |
long Job |
1 |
1 |
// Open a print job. |
1 |
Job = PrintOpen() |
1 |
1 |
/* Send the escape sequence. |
1 |
1B is the escape character, in hexadecimal. |
1 |
X indicates that you are changing the margins. |
1 |
255 sets the left margin to 0. |
1 |
040 sets the right margin to 40 character spaces. |
1 |
*/ |
1 |
<span>PrintSend</span>(Job, "~h1BX~255~040", 255) |
1 |
PrintDataWindow(Job, dw_1) |
1 |
1 |
// Send the job to the printer or spooler. |
1 |
PrintClose(Job) |