March 2, 200619 yr Hi Guys I'm working on a Mail Merge system to allow users to create template letters and use these templates to create letters to contacts. I've written a custom function to make the substituition of real data with the merge fields but I'm using it in a looping script and I'm sure it could be recursive. Any help much appreciated. MergeTest.zip
March 2, 200619 yr Author Hi Ender I did check out your CF before I posted but mine is a little different in that the merge fields do not have to be the actual field names. The merge field table deals with the translation between merge field and the actual field name. I did this for 2 reasons... 1) My field names may not be clear to a user 2) I have the ability to concatenate fields together. eg. the merge field could be <> and the substitution could be Contacts::Address1 & Contacts::Address2 etc. Besides, it's really bugging me !
March 2, 200619 yr My CF is a general way to substitute field names with their values. If you define calcs for those concatonated fields, or have the buttons insert each merge field, then the problem is solved. Since you want the CF know that the < > tag represents multiple things, and that <> really means Contact::Name, then what would be useful is if the CF can refer to the merge table to see what the real field names are that should be used, but I'll have to think a little about how to do this.
March 3, 200619 yr Author Hi Ender My CF does what I need it's just a the moment I have to loop my script to pass it new parameters to make each substitution in turn.I'm SURE this could be recursive, one parameter just needs to increment by 1 until it reaches a known value. I can pass all the info it needs in one go but just can't figure how to get it to call itself ( or at least call itself and then stop again ! ) Thanks for your help
March 3, 200619 yr To make your CF iterate through all the merge substitutions, make it recursive with the stopping condition being the number of merge values remaining = 0. Like this: //Merge ( body; mergeArray; substituteArray ) = Let( values = ValueCount(mergearray); Case(values > 0; Merge(Substitute(body; LeftValues( mergeArray; 1); Evaluate(LeftValues( substituteArray; 1)) & ¶ ); RightValues(mergeArray; values-1); RightValues(substituteArray; values-1)); body) ) Edited March 3, 200619 yr by Guest Fixed for FM7 compatiblity.
Create an account or sign in to comment