Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

This is a technique I came across some time ago that I haven't seen elsewhere, so I thought I would share it.

Often I need to know if a field is one of a number of options and perform something if it is. The straight forward way to do this is something like:


( Item = "H100" ) or ( Item = "H110" ) or ( Item = "B100" ) or ( Item = "B110" )





I have one calculation in a solution I'm currently working on that has something like 20 possibilities. I found that I could use the PatternCount function to return the same results as above in a more compact form:





PatternCount( "H100 H110 B100 B110", Item )

Assuming that Item can have only one of the possibilities (i.e., Item can't contain something like "H100

Posted

FileMaker 7 is supposed to "short circuit" calculations, meaning that once a condition is met, it stops evaluating the formula, so it processes faster. Since PatternCount() has to look through the whole text string, it would presumably be more efficient to use Position( "H100 H110 B100 B110", Item, 1, 1 ) .

Posted

If you need to force it to be a boolean, for whatever reason, not not Position( "H100 H110 B100 B110", Item, 1, 1 ) will do. I would also add spaces before and after the string to ensure partial matches don't occur. In the sample though, this doesn't seem like a strong possibility.

×
×
  • Create New...

Important Information

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