Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 5105 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I have several calculations that require a number to loop incrementally until the calculation is satisfied. What is the most simple counter that I can write as a custom function in the form of something like: Counter(Increment) ?

Posted

It really depends on the specifics. Custom functions are recursive, not iterative. Most often, you would call the next iteration with some parameter reduced by 1, until it runs out.

Posted

I understand. I'd have to make my calculations work recursively. The number that I want to increment is a divisor that just goes from 1 (+1) to whenever the result is true. It's just much easier to think of this calculation iteratively. I'd put it in a script, but that would probably run slower than using a custom function. The calculation is used for every new record and has a lot of dependencies that get updated.

Posted (edited)

Well, "the most simple counter" would be a parameter named counter, initialized to 1.

a divisor that just goes from 1 (+1) to whenever the result is true.

Not sure what that means - couldn't you use the Mod() function to get the result without recursing?

Edited by comment
Posted

Well, "the most simple counter" would be a parameter named counter, initialized to 1.

Not sure what that means - couldn't you use the Mod() function to get the result without recursing?

One of the tests and results in a case() function that I want to apply it to is something like this, where n is the divisor starting from 2, then 3, 4, and so on until it evaluates as true. If there's a remainder, it gets passed on to another calculation field that does something similar, and then a few more times. This is actually part of a slew of calculation fields that deal with remainders of an original input value. Mod() doesn't always give me the proper remainder and that's the first function that I worked with before my idea of using iterative increments.

WSTurnPageSides ≥ PageFit / n ; PageFit / n ;

Posted

I believe the condition:

WSTurnPageSides ≥ PageFit / n 




can be rewritten as:




n ≥ PageFit / WSTurnPageSides




and the smallest integer n that will satisfy the condition can be calculated as =




Ceiling ( PageFit / WSTurnPageSides )

Posted

I believe the condition:

WSTurnPageSides ≥ PageFit / n 




can be rewritten as:




n ≥ PageFit / WSTurnPageSides




and the smallest integer n that will satisfy the condition can be calculated as =




Ceiling ( PageFit / WSTurnPageSides )

That's working very well so far and it reduces a lot of calculations into one simple line. I wrote the condition like this before but missed the Ceiling() function. Thanks again for your help.

This topic is 5105 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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