PrintSend (obsolete)

Description

Sends an arbitrary string of characters to the printer. PrintSend is usually used for sending escape sequences that change the printer's setup.

Obsolete function

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

PrintSend ( printjobnumber, string {, zerochar } )

Argument

Description

printjobnumber

The number the PrintOpen function assigned to the print job.

string

A string you want to send to the printer. In the string, use ASCII values for nonprinting characters.

zerochar (optional)

An ASCII value (1 to 255) that you want to use to represent the number zero in string.


Return value

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:

  1. PrintOpen

  2. PrintSend, to change the printer orientation, select a tray, and so on

  3. PrintDefineFont and PrintSetFont to specify fonts for the job

  4. Print to output job text

  5. 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:

long Job
 
// Open a print job.
Job = PrintOpen()
 
/* Send the escape sequence.
1B is the escape character in hexadecimal.
X indicates that you are changing the margins.
030 sets the left margin to 30 character spaces.
040 sets the right margin to 40 character spaces.
*/
PrintSend(Job," ~ h1BX ~ 030 ~ 040")
... // Print text or DataWindow
 
// Send the job to the printer or spooler.
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:

long Job
 
// Open a print job.
Job = PrintOpen()
 
/* Send the escape sequence.
1B is the escape character, in hexadecimal.
X indicates that you are changing the margins.
255 sets the left margin to 0.
040 sets the right margin to 40 character spaces.
*/
PrintSend(Job, "~h1BX~255~040", 255)
PrintDataWindow(Job, dw_1)
 
// Send the job to the printer or spooler.
PrintClose(Job)

See also

PrintClose

PrintOpen