Although the title refers to "Mail-Merging" the process to be described is more accurately termed "Data-Merging" since it is by no means limited to merging names and addresses into letters or labels; any kind of textual data from a Powerbase application can be merged into any kind of document in Impression or Ovation (including Ovation Pro) or many other editors and wordprocessors.
Ovation expects data for merging to be supplied as a CSV file. An example file (OvationCSV) is supplied with this version of Powerbase. It was created from the Elements database and is intended to work with the sample Ovation document OmergeTest. Before attempting to create CSV files of your own you are recommended to read the Powerbase documentation on such files (see Ch 8). The process for mail-merging with Ovation is described below.
Ovation has a very easy method of specifying where the merged data is to go into the document. Whenever you reach a point where you wish to insert a Powerbase field type Ctrl I. A window headed "Merge tag" will appear inviting you to enter a number. The number required is the field number in the CSV record (which is not necessarily the field number in the Powerbase record). If, for instance, you wish to merge the second field from each line of your CSV file enter 2 and type Return. You will see that "[Merge2]" has been inserted into the text at the caret. Continue typing, inserting other fields as required. The fields do not need to be in numerical order (you can insert field 2 before you insert field 1) and the same field may be inserted many times. Styles and effects may be applied to the Merge tags. Load OmergeTest to see how this looks.
With OmergeTest loaded into Ovation, open the main menu, go to the File submenu and choose Print. Select the Mail merge option button and drag OvationCSV to the writable icon to the right of the button. The pathname of the file will appear in the icon. Click on OK and the document will be printed once for each record in the CSV file, merging new data into the document each time. OvationCSV contains 10 records so if you just want to see the process in action without actually printing 10 sheets of paper set your printer manager to print to a file instead of to the printer itself.
If you examine OvationCSV you will see that each field is enclosed in quotes. This is only necessary of the fields contain literal commas (see 8.1). Look at the first record, for example, and note the comma in "(Gr.aktis,aktinos; ray or beam)". Without the quotes Ovation would interpret the comma as a field separator and the merging would get out of step for that record.
The following description applies to Impression Publisher and Impression Style. The older ImpressionII, and even Impression Junior, is also supported. The name "Impression " may be taken to refer to any of these.
Direct communication and data-transfer between Powerbase and Impression or Ovation Pro can take place without the need for a CSV file. This task is performed by a module called ImpulseII which Computer Concepts have placed in the public domain to encourage its adoption as a standard means of transferring data between RISC OS applications. The !Powerbase.Resources.Modules directory contains a copy of the ImpulseII module.
To use this method of data-transfer with Impression no preliminaries, other than the preparation of the document itself, are necessary but with OvationPro you must first do the following:
(a) Open the Applets subdirectory inside OvationPro and copy the !Impulse applet into it. If your OvationPro is a recent version, supplied on CD, you will find this applet in the DavidPilling.Applets directory.
(b) The filer also needs to have "seen" the !TransDDF filter which is in the directory DavidPilling.Filters on the CD. The !Boot and !Run files of this filter need to be modified to load ASCII DDF files as described in the !Help file.
9.2.1 Preparing the document for merging
Type the document in the normal way but leave about three spaces, instead of one, between words where data from a database is to be inserted. We need to insert at these points embedded merge tags which the wordprocessor will use to tell Powerbase what to transmit. Impression and Ovation Pro employ their own methods, described in their documentation, for entering merge tags.
Powerbase does, however, have its own provision for inserting merge tags and you will find this by far the easiest way of preparing the document. Section 8.7 explained how fields can be dragged and dropped into a wordprocessor. If you hold down Shift and then drag and drop the effect is rather different. Open a blank Impression or Ovation Pro document and drag to it (without Shift) a field from a database, e.g. the NAME field from Elements. The contents of the field, i.e. the name of whatever element is displayed, will appear in the document. If you repeat the operation with Shift held down what you will see is:
There are two other useful Impulse commands supported by Powerbase and these require an alternative method for their insertion into the document. From the main menu choose Insert merge tags. The window which is displayed has a pop-up menu and bump icons to choose a field and a second pop-up menu to choose a command. First on this menu is GetField, although you'll probably find the method described above more convenient for inserting this command. Second is GetExpanded which can be used with fields linked to validation tables (see 5.4) to insert data from any column of the table. A submenu enables you to choose the column. The default is 1 which is the second column of the table.
Merging usually produces one copy of the document per record. This isn't always what we require: sometimes we want to merge data from several records into the same copy of the document. NextMatch allows us to do this. Whenever a NextMatch command is encountered, Powerbase starts transmitting the data from the next matching record without issuing an instruction to print the document or start merging afresh. This opens up the possibility of producing very fancy Powerbase reports by merging many records into a suitably-formatted document. When inserting a NextMatch command it doesn't matter what field you have displayed in the Insert merge commands window.
To actually insert a command into the document, first ensure that the correct field and command have been chosen, then place the caret at the required place in the document and drag the text file icon into the document from the Insert merge command window.
(1) Make sure the wordprocessor has been "seen" by the filer then open the Powerbase database.
(2) Data merge on the main menu opens the Data merge window and the prepared document may then be dropped on either this window or on the record window. Choosing Data merge from the menu isn't really necessary, however, since dropping the document on the record window will open the Data merge window anyway. If the wordprocessor isn't already running Powerbase will run it for you.
(3) Clicking on Merge extracts data from either the first record or, if the Merge from displayed record button is set, the currently-displayed record, and inserts it in the specified places in the document. You can see this happening if the relevant parts of the document are visible. Using the tool-pane to browse, search or change subfiles or keys now causes the accessed records to be merged into the document instead of being displayed in the record window. Each time a record is merged its data overwrites that from the previous record. When merging is in effect the default action button on the window says Merging instead of Merge.
(4) If your printer is on-line and the printer driver loaded you may print the document with the merged data by clicking on Print. If the Print all button is selected before Merge is clicked Powerbase will proceed through the database either from the beginning or, if Merge from displayed record is selected, from part-way through the subfile, merging each record in turn and printing for each record a copy of the document containing the merged data. (See 9.2.1 regarding the NextMatch command to modify this behaviour.)
(5) More often than not you will want to print only those records with certain characteristics, but where do you enter a search formula to do that? The answer is to use a filter (see 2.3.3) to limit the merge to the records you're interested in. With Print all selected, only the records matching the search formula will be printed.
(6) It is also possible to control merging via a script file (see Ch 12). Only the two commands !FILTER and !MAILMERGE (in that order) will normally be required.
It's very easy to intiate a merge operation and then remember you should have selected Print all! If this happens to you, click Stop merging. The merged data is removed from the document and the default action button reverts to Merge. You can then select Print all and start the merge again. Cancel has a similar effect to Stop merging but also closes the Data merge window. However, there is nothing to stop you reopening it from the main menu and resuming the merge process, provided the document is still open.
During a merge operation (i.e. as long as the default action button says Merging) you are prevented from editing the document. Moving the pointer over an Impression document under these conditions makes it change to a large red and blue cross and the caret can't be placed in the document. Over an Ovation Pro document there is no immediate indication but, as soon as you try to type anything, the message "Can't edit. Merge active on this document" is displayed. Both Cancel and Stop merging remove the merged data from the document and normal editing is restored. If you do want to edit the document with merged data present then click on Edit. Note, however, that if you save the document in this state it will be saved with the specific data you have merged into it rather than with the commands to merge data. Appendix A gives a full description of the Impulse commands or "methods" which Powerbase understands.
If you use neither Impression nor Ovation you may still be able to use mail-merging with your wordprocessor, but you will need to read the manual carefully to find out how. It will almost certainly involve a CSV, or similar, file in conjunction with some method of "tagging" the document (as described above for Impression and Ovation) to specify where in it the data is to be merged.
1. This feature does not seem to be supported by Ovation prior to version 1.36 and it is to that version that this information applies. (back)
2. In ImpressionII and Impression Juniorall merge tags appear in the document simply as "<Merge>", i.e. there is nothing to distinguish one from another. To see what the actual Impulse command looks like open Impression's Merge command window and place the caret immediately before the initial "<". The text of the command will then appear in the writable icon. (back)