Jump to content
Server Maintenance This Week. ×

PatternCount instead of or


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

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

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