Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Could this be recursive ?

Featured Replies

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

Check this CF:

http://www.fmforums.com/forum/showtopic.php?tid/120434

  • 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 !

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.
  • 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

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 by Guest
Fixed for FM7 compatiblity.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.