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.

Need help with a recursive function

Featured Replies

Hey Guys I've wrote this function but just can't get it to work. The plan is to inject some content (template) and for it to iterate through each word looking for a formula, i.e. {{If([[CarMake]] = "Volvo"; "Volvo" ; "Other" )}} and evaluate it. I think the calculation I have is working fine, but I can't quite manage to work out how to loop through each word in the content. I've tried to reverse engineer Ray Cologens Mail Merge formula as that custom function kind of did what I needed, but I didn't need all of it.

Thanks in advance.

 

 

MergeText(Template)

Let([

start_pos = Position(Template; "{{"; 1; 1);
end_pos = Position(Template; "}}"; start_pos; 1);
formula = Middle(Template; start_pos + 2; end_pos - start_pos - 2);

formula_VARS = Substitute(formula ; 

    ["[[CarMake]]";"$CarMake"];

    ["[[CarModel]]";"$CarModel"];

    ["[[CarType]]";"$CarType"]
);

original_formula = "{{" & formula & "}}";

evaluated_formula =  If(EvaluationError(Evaluate(formula_VARS)); "Invalid Formula"; Evaluate(formula_VARS))
]
;


Case(
    Right(Template ; 1 ) <> ¶ ; MergeText(Template & ¶) ;

    start_pos > 0 and end_pos > start_pos ; MergeText(Substitute (Template ; original_formula ; evaluated_formula ) ) ;

Template

    )

)

 

 

You did not explain what the function is supposed to do. Looking at it superficially, it would seem a simple Substitute() could do the job?

Create an account or sign in to comment

Important Information

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

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.