[softwarelist] Ovation stripping blank mail merge fields

  • From: David Pilling <flist@xxxxxxxxxxxxxxxxxxx>
  • To: davidpilling@xxxxxxxxxxxxx
  • Date: Tue, 15 May 2007 22:00:03 +0100

Hi,

Long ago, someone pointed out to me that his mail merge data had a fixed
number of fields for addresses. The problem was that not all addresses
had data for all the fields and the post code was in a separate field at
the end. The result was that he would end up with blank lines between
the address and the post code in the final merged document.

Ovation Pro has a system of "fields" which can contain script language.
Using these it is possible to remove blank fields from mail merge data.
All this is described in the Ovation Pro reference manual - see chapter
12.

Today someone came to me with a problem, their mail merged document
looked a mess. It turned out that the data contained not just blank
fields in the address, but in other fields.

The script language function that does all the work of stripping blank
fields, is:

string merge_strip(int n,int max)

and it lives in the file Library.!MergeLib

Now it turns out that this function finds the n'th non-blank field
starting from the first field in the record. Looking at it today that
seems rather limited, it makes the big assumption that there is probably
just a name before the address.

Anyway I defined a new function:

-------------------------------------------------8<----------------------
--------------


string merge_strip2(int n,int min,int max)
{
 int i=min;
 int j=0;

 while(j<n && i<=max)
 {
  if(field(i)!="")j++;
  i++;
 }

 return((j<n)?"":field(i-1));
}


-------------------------------------------------8<----------------------
--------------

This allows you to specify the n'th non-blank field between records min
and max. This is the typical string you would fill in to the field
window in Ovation Pro.

{macv=merge_strip2(1,5,11)}

for the first line of the address, then:

{macv=merge_strip2(2,5,11)}

for the second and so on.

This new function will appear in future versions of OP, in the !MergeLib
file. In the meantime if you want to use it, copy and paste the bit
between the cut lines above into !MergeLib (after the existing
contents!).



-- 
David Pilling
email: david@xxxxxxxxxxxxxxxxxxx
  web: http://www.davidpilling.net
 post: David Pilling P.O. Box 22 Thornton Cleveleys Blackpool. FY5 1LR UK
  fax: +44(0)870-0520-941



Other related posts:

  • » [softwarelist] Ovation stripping blank mail merge fields