Chuck Posted October 7, 2004 Posted October 7, 2004 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
Ugo DI LUCA Posted October 7, 2004 Posted October 7, 2004 Hi, Yes it is actually clever. Got it from BobWeaver myself, but true is it is a rather unknown feature which has its place in a own post. Bob's calc Thanks
Fitch Posted October 7, 2004 Posted October 7, 2004 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 ) .
-Queue- Posted October 7, 2004 Posted October 7, 2004 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.
Recommended Posts