PrintCancel PowerScript function
Description
Cancels printing and deletes the spool file, if any. Cancels
printing of a print job that you opened with the PrintOpen function.
The print job is identified by the number returned by PrintOpen.
For syntax for DataWindows and DataStores, see the PrintCancel method
for DataWindows in the DataWindow Reference or the online Help.
Syntax
1 |
<span>PrintCancel</span> ( <span>printjobnumber</span> ) |
Argument |
Description |
---|---|
printjobnumber |
The number the PrintOpen function |
Return Values
Integer. Returns 1 if it succeeds and
-1 if an error occurs. If printjobnumber is null, PrintCancel returns null.
Usage
PrintCancel cancels the specified print
job by deleting the spool file, if any, and closing the job. Because PrintCancel closes
the print job, do not call the PrintClose function
after you call PrintCancel.
Examples
In this example, a script for a Print button opens
a print job and then opens a window with a cancel button. If the
user clicks on the cancel button, its script sets a global variable
that indicates that the user wants to cancel the job. After each
printing command in the Print button’s script, the code
checks the global variable and cancels the job if its value is true.
The definition of the global variable is:
1 |
boolean gb_printcancel |
The script for the Print button is:
1 |
long job, li |
1 |
1 |
gb_printcancel = FALSE |
1 |
job = PrintOpen("Test Page Breaks") |
1 |
IF job < 1 THEN |
1 |
   MessageBox("Error", "Can't open a print job.") |
1 |
   RETURN |
1 |
END IF |
1 |
1 |
Open(w_printcancel) |
1 |
1 |
PrintBitmap(Job, "d:PBitmap1.bmp", 5, 10, 0, 0) |
1 |
IF gb_printcancel = TRUE THEN |
1 |
<span>   PrintCancel</span>(job) |
1 |
   RETURN |
1 |
END IF |
1 |
1 |
... // Additional printing commands, |
1 |
... // including checking gb_printcancel |
1 |
1 |
PrintClose(job) |
1 |
Close(w_printcancel) |
The script for the cancel button in the second window
is:
1 |
gb_printcancel = TRUE |
1 |
Close(w_printcancel) |