Jump to content

Conditional based on PatternCount for WHOLE (not part of) numbers


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

Recommended Posts

I elaborated a bit on this technique, more specifically the showing/hiding of things in portal rows based on conditionals.

I wanted to show or hide a "delete portal row" button in a QUE_ANS portal on a QUE layout using this conditional statement

PatternCount ( QUE::Emps ; QUE_ANS::_Emp_IDfk ) > 0

QUE::Emps is a multi-line field holding Employee IDs.
QUE_ANS is a portal on the QUE layout, based on QUE::__Question_IDpk = ANS::_Question_IDfk.
QUE_ANS::_Emp_IDfk is a single-line field holding an Employee ID.

My challenge is to SHOW the "delete portal row" button on a row in the QUE_ANS portal in case the QUE::Emps does NOT contain the QUE_ANS::_Emp_IDfk value.
I soon found out that PatternCount has its flaws: the conditional statement above will evaluate as TRUE if QUE::Emps holds for example "99" and QUE_ANS::Emp_IDfk is "199", even if those values are not equal.

There seems to be no xCount function for an EXACT match of numbers (or words).
The functions "ValueCount" or "WordCount" are no use, as they take 1 parameter only, they count things, they don't search.
The function "Exact" compares ALL of QUE::EMPS with QUE_ANS::Emp_IDfk, not a single line, so no use either.

Google to the rescue. I changed my conditional to:

PatternCount ( "¶" & QUE::Emps & "¶" ; "¶" & QUE_ANS::_Emp_IDfk & "¶" ) > 0

Pre- and post-pending both base and search string in the PatternCount function with a paragraph character seems to do the trick (as the search string must now be a whole line). Can anyone confirm? Or any better techniques without the use of Custom Functions (no FMP Advanced here)?

Edited by Roeland De Windt
Link to comment
Share on other sites

This topic is 2846 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.