CreatePrintJob()
Places a print job request directly into the Visual Builder print job queue.
Syntax
CreatePrintJob(<cForm>, [<cScript>], [<nCopies>], [<cSpool>], [<nPriority]>) --> lResult
Arguments
<cForm> --> is the name of the Visual Builder form to print. Do not specify the path or form's file extension.
<cScript> --> is an optional character string containing a script that Visual Builder will execute before it executes the form.
<nCopies> --> the number of copies to print. If not specified, the default is 1.
<cSpool> --> optionally specify the spooler to insert the print job into. If not specified, the print job request is inserted into the default spool file.
<nPriority> --> optionally specifies the job's print priority. The range is 1-4, with the highest = 1, and the lowest (normal) = 4. The default is 4. Print jobs with a priority of 3 print before print jobs with a priority of 4; print jobs with a priority of 2 print before print jobs with a priority of 3, and so on.
Returns
If the print job was successfully entered in the print queue, TRUE is returned. Otherwise FALSE.
Description
This is a special purpose function that allows a report to scan a database and selectively indicate which records are to be printed and which Visual Builder form is to be used to print them. For example, it is possible to create a report that scans the Service Manager job card database and selectively prints job cards, using this function.
In order for the above to function usefully, there must be a relationship between the report that creates the print job requests and the form that prints them. Using the Service Manager as an example, the standard Service Manager Job Card form checks for the variable FirstTran in the Preface section of the form. The contents of this variable instructs the form on what job card to print.
By creating a script that assigns this variable a value, the JOBCARD.STY form can be instructed to print the job records indicated by the report that executes the CreatePrintJob() function. The general procedure is:
1. Create a report that scans a selected database.
2. If custom conditions are met, the CreatePrintJob() function is executed.
3. This report outputs its contents to "none". (There is no particular reason to print this report unless you want a list of the records that forms will be printed for.)
4. Ensure that the CreatePrintJob() function passes a script to the indicated form, so that the form can use it to determine which records to print.
5. When the report finishes printing, new print jobs will be placed in the print queue. Visual Builder will automatically start printing these queued print jobs.
Example
Assuming that the Report Wizard was used to create a Service Manager Job Card report, a function can be added to the Rules section of the body, or a body field can be added, containing this formula:
* Check if the job card's category is 'STORE'
* The form 'JOBCARD' will be added to the print
* queue if this condition is met.
If smjobs->Category = "STORE"
* Create and temporarily assign the variable 'JobScript'
* the script that 'JOBCARD' will process:
Declare JobScript Type Character
JobScript := "Declare FirstTran Type Character"
JobScript := JobScript + CHR(13) + CHR(10)
JobScript := JobScript + "FirstTran := '" + smjobs->Job + "'"
* Assuming the job number was 1000, the 'JobScript'
* variable would have the following contents:
* Declare FirstTran Type Character
* FirstTran := '000001000'
* Add job to print queue and assign it the above script
CreatePrintJob("JOBCARD", JobScript)
* If this formula is placed in the Rules Section
* always RETURN TRUE
Return "Yes"
Endif
* If this formula is placed in the Rules section
* always RETURN FALSE
Return "No"
____________________________
Related Topics: