FutureBasic Logo

<<    Index    >> FutureBasic

Appendix H - Printing   appendix

You may envision the printed page as something very similar to a window. In general, commands used to produce any type of display on the screen will produce a similar imprint on the page. The exception would be controls which cannot be sent to the printer port.
You instruct your program to switch to the printer using the route command.

route _toPrinter
// printing commands here
route _toScreen

You may freely switch back and forth between the printed page and the screen by executing route commands. When it is time to eject a page or to terminate printing entirely, you can clear the page with clear lprint or close down the printer (which has the side effect of automatically clearing the page) with close lprint.

Page size
You can query the printer as to how large the page is by routine output to the printer, then executing window() functions.

route _toPrinter
pageWidth = window(_width)
pageHeight = window(_height)
route _toScreen

Print dialogs
Two dialogs are used before printing. The first is a style dialog that lets the user determine page orientation, scaling, and other items. This is usually brought up in response to selection of the Page Setup item under the File menu.
The second common dialog is a job dialog. It lets the user determine how many copies will be printed, which page numbers will be included, and other items that vary from one printer to the next. The job dialog is brought up with def lprint and is normally displayed before each print session. Note that the Print Manager actually handles the details of the job. If the user wants to print 2 copies of pages 7 through 10, your application may happily print a single copy of the entire document and the Print Manager correctly filter the output to adhere to the user's request.

Do not call clear lprint or close lprint when output is being routed to the printer. This may cause the system to crash. Instead, route output back to the screen, then clear or close.

Appearance manager printing
Because buttons cannot be sent to the printed page, Appearance Manager edit fields cannot be printed. There is a simple work around. Create the edit fields in a window, then use the edit field statement (with only the field number as a parameter) and it will be copied to the printer. The following example shows how this is done.

window 1
edit field 1, "This is a test", (10,10)-(120,32)
// Now print it
route _toPrinter
edit field 1
route _toScreen

In this example, we did not clear or close the printer (clear lprint or close lprint). This is because the operation is automatically performed when the program terminates.