Tuesday, November 1, 2005

Extending the automated signature generator


By Mick Moignard

This is the last part of our "Building an automated signature generator application" series. If you haven't read the previous three parts, you'll find links to them at the end of this article. In this week's installment, we'll learn how to extend the program with new fields.

What else can it do?

What else can we talk about? How about extending it to use new fields? This is pretty easy -- there are a number of simple steps.

First, add the field to the main form. I'd suggest using the same name all the way through the code; makes it easier. Of course, you will find that I haven't always done that, but such is life. Check the SignatureData form, and see, for example, where I added the field Strapline.

Next, add the new fields to the placeholder insertion code. This has to be done twice, once in each template form. In each form is the Action "Insert Placeholder". This contains the code we saw a bit back:

promptlist:= "HTTP Link 1":"Logo Image 1":"Logo Alt 1":"HTTP Link 2":"Logo Image 2":
"Logo Alt 2":"User Name":"Email":"Job Title":"Phone":"Fax":"Site Address":"Map Street":
"Map Country":"Map City":"Map PostCode":"Department":"Room":"Company":"Cell Phone":
"MAP URL":"Strapline";
fieldlist:= "http":"http_image":"http_image_alt":"http_1":"http_image_1":
fieldname := @Prompt([OkCancelList]; "Select Field"; "Select the fieldname to insert as a placeholder"; "";promptlist);

All you have to do here is to add a title for the new field to the value list for promptlist, and add the actual placeholder name -- use the field name -- in fieldlist's value set, at the same place in the list. Make sure that those two lists are balanced. Have the same number of elements and in the same order.

Lastly, you need to add a line of code to each of the Render clicks on the SignatureForm; one is the Format the Text action, and the other is the Render HTML button. Add a line into the case statement that looks like this:

Case "STRAPLINE": text = Mid(text,1,i-1) & doc.Strapline(0) & Mid(text,j+2)

You need to change the literal at the start of the statement to the name of the placholder, and the doc.xxx(0) is the name of the data field on SignatureForm.,

You might also want to add fields to the site location documents. If you do, you will need to add them to the Location form, and then add fields to match to SignatureForm. Then you alter the "Click to get your Site Details" code, which looks like this: