"SBase Personal - 13. PRINTING DATA AND FORMS" 13 PRINTING DATA AND FORMS Page Setup and Font Selection Creating or Modifying Printer Control Files Printing Forms Form Fonts Printing Views Show or Hide Field Names Single Records and Forms Printing the Current File Using Project Print File 13 PRINTING DATA AND FORMS The Print command in the Project menu allows you to select what to print, and, as examples, the options to print the current record and the current file are described in this chapter. Both options may be used with or without forms. See Chapter 14 Defining and Using Queries for information on printing queries. See Chapter 31 Customizing Your System for information on printing the Status screens. The appearance of any printed output, however, depends upon the features available in your printer and SBase 4's ability to utilize those features. You are supplied with several printer control files (such as S:SB_EPSON.INI, S:SB_LASERJET_III.INI and so on) which contain the details SBase 4 needs to operate various printers, and before you print from SBase 4 for the first time you should run the Printer Setup command in the Set menu to specify to SBase 4 the type of printer you intend to use. The same printer type should also be selected in Printer Preferences on the Workbench as well. Most printers, in addition to their normal typeface, can print in underlined, italic or bold typefaces. Some printers have various fonts available, such as Courier, Times Roman, Univers and so on, and possibly several sizes of each font. The Printer Setup command allows you select the font and size from all those available on your printer, and you can specify underlined, italic or bold typefaces where required in the output from queries and reports. Page Setup and Font Selection If you are using a form, the page dimensions and font selection are taken from the form itself. However, if you intend to print single records or lists you should use the Printer Setup command on the Set menu to define the font, the font size and the page margins for printed output. Selecting Printer Setup from the Set menu first displays a Change Printer requester like this: *** See Fig 13-1 *** A list is displayed of all your printer control files. You may need to scroll the list to see all of the names. If any printer control file is currently selected, its name appears in the one-line box below the main box. What you have to do is to ensure that the printer control file selected matches the printer that you intend to use, or corresponds to a printer with which your printer is exactly compatible. If you need to set for the first time or to change the name of the selected printer, point to the name you want in the list and click the mouse button. When you are sure the correct name is selected (displayed in the one-line box), click on OK. If no displayed name quite matches your printer, see Creating a New Printer File, later in this chapter. One additional filename appears in the list of printer control files - it is PREFS. This refers to the printer specified in Workbench Preferences. You may select the PREFS printer if you wish, but in the Page Setup requester (described below) you will be able to alter only the Initialize field. When you have selected your printer, click on the OK button and the Page Setup requester is displayed as shown below: *** See Fig 13-2 *** 1. Examine, and change if necessary, the values set for the width and height of the paper that your printer uses. These are the overall dimensions of a sheet of paper, not the area within which you want to print. You can specify the size in either inches or centimeters, depending on which of the buttons near the bottom of the requester marked `Inch' and `CM' is selected. 2. Specify the left, right, top and bottom margins, again using either inches or centimeters as specified by the `Inch' and `CM' buttons. 3. If your printer will start a new page after being sent a `form feed' character (ASCII 12), then click the Form Feed button so that it is checked. If your printer does not correctly handle a form feed character, leave this button unchecked and SBase will send as many blank lines as necessary at the bottom of each page to ensure printing starts at the top of the next page when required (although this method is not quite as reliable as sending a form feed). 4. Click the Single Sheet button so that it is checked if you need SBase to pause at the end of each page of printed output (so that, for example, you can load special stationery one sheet at a time). 5. If the printer has a variety of fonts and/or sizes available, the currently selected font and size are shown in the one-line box that has an upward pointing arrow at its right. Click on the arrow repeatedly to cycle through all the available fonts and sizes, and stop when the combination you want is displayed. 6. The remaining one-line box is the `Initialize' box. This contains the codes that SBase must send to the printer whenever it needs to be sure that the printer is in a known state (at the top of a new page with underlining, italic and bold all switched off, for example). You should not need to change these values unless you are creating a new printer control file. Note Although SBase 4 does not support proportional fonts on screen (except on forms), you may select a proportional font for printing using the Printer Setup command. If you do use a proportional font you should avoid instructing SBase 4 to position printed output according to `column' number. All the SBase 4 Print commands - in the Project menu - adopt the settings that are specified with Printer Setup. Whenever you modify the printer settings, SBase saves the name of the selected printer control file in the S:SBPER4.INI file. So if you intend to use the same format for all your printed output, you only need to select the Printer Setup command once. If you wish to define a different format for each type of print operation - for example: printing single or multiple records, printing in different view modes, or printing status information - you should use Printer Setup before selecting one of the print commands. Creating or Modifying Printer Control Files In the majority of cases one of the supplied printer control files will enable SBase to exploit the features of your printer correctly. If, however, your printer is not supported by one of the standard control files you should be able to create a suitable printer control file of your own. All SBase 4 printer control files have names of the form: S:SB_printername.INI where printername is, for example, EPSON or LASERJET_III. You should not change any of the supplied printer control files, in case you later need them in their original form, but you should use one of the existing files as a model because you will probably need to make only minor changes. To create a new printer control file, use a text editor. SBase 4's text editor is one that is suitable for this purpose and its use is described in Chapter 23 of this manual. Run the text editor, read into memory the existing printer control file that is nearest to the one you need, make the necessary changes, and save the results in a new file with a name of the form given above. As an example, the following listing shows typical contents of a S:SB_LASERJET_III.INI printer control file: Fontname=Line Printer 8.5 Width=21.0 Length=29.7 Initialize=27,"E" Left=0.5 Right=1.0 Top=1.0 Bottom=6.0 Ffeed=1 Ssheet=0 INCM=0 Font=Courier 12 pt Plain=27,"(8U",27,"(s0p10.00h12.00v0s0b3T" BF ON=27,"(s3B" BF OFF=27,"(s0B" UL ON=27,"&d0D" UL OFF=27,"&d@" IT ON=27,"(s1S" IT OFF=27,"(s0S" CPI=10 LPI=6 SETCPI= SETLPI=27,"&l6D" Font=Line Printer 8.5 Plain=27,"(8U",27,"(s0p16.67h8.5v0s0b0T" BF ON=27,"(s3B" BF OFF=27,"(s0B" UL ON=27,"&d0D" UL OFF=27,"&d@" IT ON=27,"(s1S" IT OFF=27,"(s0S" CPI=16 LPI=8 SETCPI= SETLPI=27,"&l8D" Most lines start with a keyword, then have an equals sign and finally a series of one or more values, separated by commas. The empty lines that separate the groups are ignored by SBase 4. The first group of lines specify values that apply whenever this printer control file is selected. They show which font is currently selected on this printer, and the current values of all the items that you can set with the Page Setup requester (described above). Each subsequent group of lines refers to a particular font. Only one of these groups of lines will apply at any one time - the group having the font name currently specified in the Fontname line at the beginning of the file. The first line of each group of lines after the first identifies the font name, and is followed by lines which specify the codes that SBase 4 must send to the printer in order to switch certain features on or off. The keywords used and their meanings are as follows: Keyword Meaning Plain Boldface, underline and italic off BF ON Boldface on BF OFF Boldface off UL ON Underline on UL OFF Underline off IT ON Italic on IT OFF Italic off CPI Pitch (characters per inch) LPI Line spacing (lines per inch) SETCPI Reset CPI value SETLPI Reset LPI value Each line but the first, in the second and later groups, has a series of values after the equals sign. This series of values represents a series of bytes to be sent to the printer, and bytes may be specified in any one of three ways: individual decimal ASCII values, individual hexadecimal ASCII values, or a text string. For example the string `Xyz3' may be specified as any one of: "Xyz3" 88,121,122,x33 x58,x79,"z",51 To find the series of bytes needed to perform each of the above actions on your printer, refer to your printer's technical reference manual. Each series generally begins with an ESCAPE character (ASCII 27), and these series of bytes are often referred to as `escape sequences'. Printing Forms Forms designed with the Form Designer may be printed from within the database. You can achieve a high degree of page fidelity to the screen, but the differences between fonts on different printers and between screen and printer fonts can lead to some discrepancies between what you see and what is printed. You print forms with the same commands used when printing without forms: Print Record and Print File, both in the Project menu. They are described below. Form Fonts If you are designing a form that will not normally be printed, such as a specialized data entry screen, you should use screen fonts for all text. If you intend your form to be printed, and you know that the same printer will always be used, it is best to design it with fonts offered by the driver for that printer. The Form Designer and SBase 4 will agree about the nearest font to use for screen display. However, if your form may be printed on different printers, for example if you are designing a form for use by several individuals in your organization, you should try to use fonts that are offered by most printers, such as Roman, Script or Modern. Even so, minor differences in fonts designed by different printer manufacturers may cause small problems when printing text. Printing Views Before printing records with the Print command (on the Project menu), you should select the view mode you require using the Set menu. SBase 4 prints records in the format of the current view mode: - In Table View, the field names appear as column headings, separated from the first line of data by a blank line, on each page. If the field data and names extend beyond the right margin, they are wrapped onto the next line. SBase 4 then inserts a blank line before printing the next record. - In Record View and Page View, records are not split over two pages; if there are not enough lines at the bottom of a page to print a record, SBase 4 skips to the top of the next page. Record data that extends beyond the right margin is truncated. - In Record View, SBase prints a blank line between each record. In Page View, it follows the blank line with a line of dashes. Show or Hide Field Names If field names are displayed on screen, they will also be output to the printer. Before printing records, you can use the Show Field Names command on the Set menu to specify whether the field names are to be printed or not. - In Table View, the field names appear as column headings, separated from the first line of data by a blank line, on each page. You may need to drag columns to the right on screen to set a width sufficient to avoid truncation when printing in some proportional fonts. - In Record and Page View, the field names, which are shown on screen in reverse video, are printed normally. Single Records and Forms The Print Record command on the Project menu prints the current record or form. When you want to print a single form, follow this procedure: 1. Open the form with Open/Form on the Project menu. Any required files will be opened. 2. Select the data you want to print. 3. Select Print and Record on the Project menu. The Print Options requester appears: *** See Fig 13-3 *** SBase 4 only invokes the Print Options requester when you have a form open. It allows you to choose whether to print the current page or the whole document if your form has more than one page. You may also choose which classes of graphic objects are to be printed. Areas, boxes, lines, text, and images on forms will all be printed unless you turn off the relevant check box. Make the selections you want and click OK. You should obtain a reproduction of the screen form on the printer. - Remember that form objects designated as non-printing - such as operator prompts - will not be printed. If you are printing without a form open, simply select the record to be printed and then choose the Project Print Record command. The command makes a copy of the record as it appears on screen in the current Page or Record View. As well as the contents of the record, it also prints field names if they are shown on screen. Unless you are printing a form, Project Print Record uses the printer and page settings that are specified with the Set Printer Setup command. Printing the Current File The Print File command on the Project menu provides a quick and easy way of obtaining a printout from the current file. This command should also be used when you want to print a series of forms. If you have a form open, Print File outputs data using the form. If you are not using a form, Print File outputs the currently selected fields list in the format of the current view mode, using a standard Filter. If field names are shown on screen, these are printed as well as the field data. Records are printed in the order of the current index. The Print File command displays a Print Order requester which allows you to to change the current index, and to select either ascending or descending order. You may also make selections from the Print Options requester (see above). Note Make sure that your printer is connected and is on-line before you commence any printing. Using Project Print File 1. Select Print and File from the Project Menu. 2. SBase 4 displays the Print Filter. *** See Fig 13-4 *** - The requester is the same as the normal Filter requester. See Chapter 10 Retrieving Data Interactively for a detailed explanation of how filters work. - The filter applies to the current file only, even when a multi-file form is in use. Filters defined for files other than the current file are used. 3. Build up your Filter command line and click OK. 4. SBase 4 displays the Print Order requester. By default, records are printed in the order of the current index. If you wish to change the index, you can select another index from the List box. 5. Click in the Descending check box, if you wish the records to be printed in descending order. Then click OK. 6. Select Single Page or Whole Document from the Print Options requester, and turn off any class of graphic object you do not want to print. Click OK to print the form. Unless you are printing a form, the Process Print command uses the printer and page settings specified with the Set Printer Setup command.