Historically, to print to a printer, BR used the file number 255, which was reserved for this purpose. With Native Windows Printing now compatible with BR, this is no longer necessary. In this tutorial, we will attempt to explain both, so that you will be comfortable with both older and newer printing jobs.
Printing with #255, means it must also first be OPENed, PRINTed to, and then CLOSEd, as in this short example:
00010 OPEN #255: "name=PREVIEW:/DEFAULT,recl=32000", DISPLAY,OUTPUT 00020 PRINT #255: "My first printout!" 00030 CLOSE #255:
We use a print preview to save paper for the examples in this tutorial. To print to an actual printer, change PREVIEW to PRN.
Originally, BR used non-proportional fonts, so to print correctly on the page, it was important to pay attention to the lines and spaces so that everything lines up correctly. If you are updating legacy reports, it's simplest to choose a modern-looking non-proportional to work within the constrains of legacy alignment. For creating a new report, however, you probably wish to use a modern proportional font since you'll be aligning everything for the first time.
BR programs often use the FORM statement to format the printout. For example:
print #255,using nameform: A$(1),A$(2),A$(3) nameform: form Pos 14,C 30,Skip 1,Pos 14,C 30,Skip 1,Pos 14,C 30,Skip 8
will simple print a blank line. Skip 1 will do the same. All lines will perform a carriage return and start the next line one down, unless it's followed by a semi-colon (;).
print #255, using curform:B(2),B(4),B(5),B(12),sum(mat B(13:21)) curform: form pos 102,pic(z,zz#.##), skip 1
The syntax then, for PRINT USING, is as follows:
PRINT #255, USING line-ref or string expression : data item or MAT array-name
In the example above, curform is the line ref and the data items are listed after the colon. Within the line curform, notice that most normal format specifications apply to print statements too.
Using a file Printer.sys, you can set fonts and styles using subattributes too.
If the program does not use #255, then the printout goes to prn:/10, which would be the currently designated printer.
Printing instructions to a printer usually follows a top to bottom, left to right format. Therefore, imagine the cursor jumps from your program to the printer and continues to follow your commands. If you jump down four lines to print an address, for example, it can only mover further to the right or down to the next line, but not up or to the left (of course, there are ways to manipulate around this too, see the commands described below). So when you program your printouts, plan ahead and complete the printing instructions line by line.
Several commands allow you to position the cursor for printout.
POS allows you to start printing at any place in a line. Likewise, ROWPOS will do the same. COLPOS will position the cursor according to a place in the current column. ROW and COL can also be used to position the printout.
Push and Pop
Here's where we can get around the top to bottom, left to right path of the printer pointer. [PUSH] will save the printer's position, then lines can be printed, and [POP] will return the cursor to the place where it saved for itself, and continue printing again. For example, if on an invoice, you enter [PUSH], then print the items in one column, use [POP] to return again to the saved position and then move right to print the date in the same column. It all depends on how your information is organized and what needs modifying in printer commands that have already been written by other programmers.
print #255, using "form C,SKIP 0" :"[push]" print #255, using descform: "SAL.","O.T.","ADD'L","HOL.","Vac.","Sick" descform: form pos 18,c 5,skip 1 print #255:"[pop]";
Printer.Sys, like BRConfig.sys, allows you to use substitution statements to control printing, including font, style, and adding pictures, boxes and shading.
Print Preview Window
To first display a print preview window, this can be added to the BRConfig.sys file:
Substitute WIN:/ PREVIEW:/
Or, the preview can be started from the program itself using this command:
00100 OPEN #255: "name=preview:/select",display,output
As of 4.2, BR saves the PREVIEW window "position" and "maximized" settings across sessions.
During PREVIEW, clicking "Print (all)" produces a standard Windows print dialog box so the user can specify copies, range and other printing options.
The PREVIEW window continues to be non-modal (permitting multiple concurrent previews), but we suppress the raising of the initiating window in response to waiting for keyboard entry until the PREVIEW window is closed. This avoids the eclipsing of the preview window by the initiating window.
Connecting to Different Printers
Printers can be designated for printing in the BRConfig.sys file. Simply add the printer location after PRN:/ in the program or in BRConfig.sys.
With BR version 4.0 and following, Native Windows Printing is allowed. To activate this, make sure that OPTION 31 is off, and specify WIN:/ as the device type in your OPEN #255 statements or BRConfig.sys file. For example:
00010 OPEN #255: "name=WIN:/DEFAULT,recl=32000", DISPLAY,OUTPUT 00020 PRINT #255: "My first printout!" 00030 CLOSE #255:
"DEFAULT" will send your print out to the default printer.
00010 OPEN #255: "name=WIN:/SELECT,recl=32000", DISPLAY,OUTPUT
"SELECT" will cause the window for selecting a printer to open up, allowing the user to choose which printer to send the information to.
00010 OPEN #255: "name=WIN:/EPSON 2,recl=32000", DISPLAY,OUTPUT
To send the information to a specific printer other than the default printer, add the first part of the printer name (enough to make it unique) and it will be recognized and sent.
Printouts can be sent to different printers using SUBSTITUTE commands which can be added to BRconfig.sys.