----
When the data window of continuous paper printing is used, the page length needs to be customized to ensure that the printer runs correctly without manual intervention to achieve continuous printing. In PB, an external function must be called to customize the paper length, which is cumbersome. This article introduces a method to directly control the printer and easily set the page length.
----
I,
Prerequisites
----
The communication between the computer and the printer is carried out using ASCII codes. The standard ASCII codes include printable and non-printable characters (control codes). The printer uses control codes to customize the printer. Most printer commands use the control code escape as the first sequence of their command sequence. The following describes the sequence of instruction codes used in this article:
Set line feed (line spacing)
1/8 inch
ASCII
Code
ESC 0
Decimal code
27 48
Set the page length in the unit of behavior
ASCII
Code
Esc c n
Decimal code
27 67 n
Where
N indicates the number of rows per page (1-127)
----
II,
Transmission of control codes in pb and implementation of custom page lengths
----
In PB, the control code is sent to the printer through the Printsend function (printjobnumber, string, {zerochar. Parameters are defined as follows:
Printjobnumber:
Print the job number returned by the printjob () function;
String:
Control string, using ASCII code;
Zerochar:
Used to replace the number 0 in string;
----
Because 0 in the string terminates the string, if the string
If it contains 0, other characters must be used to indicate 0. The zerochar parameter is used for this purpose. When PB sends a control string to the printer, the replacement character zerochar is converted to 0.
----
The following is a specific program for completing the customization page to print data windows (the customization page is 2.75 inch ):
Long ll_job
Dw_print.reset ()
Ll_job = printopen ()
If ll_job =-1 then
Messagebox (gs_title ,"
Printer not ready ")
Return
End if
//
Custom line spacing: 1/8 inch
PrintSend (ll_job, CHAR (27) + CHAR (48 ))
//
Set the page length to 22 rows
PrintSend (ll_job, CHAR (27) + CHAR (67) + CHAR (22 ))
Printdatawindow (ll_job, dw_print)
Printclose (ll_job)