Jump to content
Server Maintenance This Week. ×

How can a boolean test return true and still fail?


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

Recommended Posts

I have been using ISO Filemaker Magazines Permissions Template for going on 4 years now without issue.  However, recently I have started to notice some very odd inconsistencies with permission checking.  If you're not familiar with this Template, it compares a users set of "Permissions" (in this case, a list of text strings representing the users permissions) against a Script Parameter that contains the permission to check.

I have started to encounter instances of this check failing even though the global field clearly contains the Users permission.  The check is performed by checking if the value of the Script Parameter is contained within a Global field that contains a list of all of the Users permissions.

 

The first thing I did was to get the position of the permission that I am getting.  In this case, the it is value number 51 in the list:

GetValue ( Globals_AccountCheck::User_Permissions ; 51 )

Which returns "Company Tab • DeptContracts • Provider Networks • Manage".  Next, I checked that the Script Parameter being passed is consistent with the Permission that I am checking for and that there are no spelling errors or anything like that:

Get ( ScriptParameter ) = "Company Tab • DeptContracts • Provider Networks • Manage"

I then use the function to asses whether the Global field contains the permission we're checking for (This usually checks the entire contents of the Global field which contains all of the users permissions, but in this case I'm making double sure that the value being checked is present...)

PatternCount ( GetValue ( Globals_AccountCheck::User_Permissions ; 51 ) ; permissions ( Get ( ScriptParameter ) ; "returns" ) )

And this returns False.  And here's the kicker:

GetValue ( Globals_AccountCheck::User_Permissions ; 51 ) = Get ( ScriptParameter )

Returns TRUE.  How is that possible?  How can a value that I KNOW is contained within a list FAIL when using patternCount and FilterValues, and return TRUE when I compare the two strings?  I've triple checked to make sure that the data types are the same.  I feel like I'm missing something very basic here, and that scares me...

Link to comment
Share on other sites

The equals operator returns True for certain characters that are not exactly the same, like uppercase vs. lowercase and (this I discovered only this week) Char ( 32 ) (space) and Char ( 160 ) (non-breaking space). Functions like Exact, PatternCount, Filter, and FilterValues can be more demanding, requiring that each character really be exactly the same. I would double-check that the case and space characters really are exactly the same between the two strings you're comparing. When I don't know where the offending character is, I sometimes troubleshoot these issues by using Code () on the characters of each string one-by-one and comparing.

  • Like 2
Link to comment
Share on other sites

The equals operator returns True for certain characters that are not exactly the same, like uppercase vs. lowercase and (this I discovered only this week) Char ( 32 ) (space) and Char ( 160 ) (non-breaking space). Functions like Exact, PatternCount, Filter, and FilterValues can be more demanding, requiring that each character really be exactly the same. I would double-check that the case and space characters really are exactly the same between the two strings you're comparing. When I don't know where the offending character is, I sometimes troubleshoot these issues by using Code () on the characters of each string one-by-one and comparing.

 

Whelp, that turned out to the the issue.  Code( ) showed some obvious differences between the two strings, so I guess I'll be more careful in the future when it comes to comparing two values.  Is this a recent change?  My users and I have been using FM13 for about 4 months now, and only recently have they started complaining about their permissions not working correctly.  

I recently worked on an entire project in FM13 and as far as I know, NONE of the permissions that I added via FM13 were working correctly.  I didn't notice as I usually bypass the permissions as a Developer, but once I removed the work-around I started to experience the same results.

Link to comment
Share on other sites

Is this a recent change?

 

Is what a recent change? Some functions being case-sensitive and others not? No, that goes way back.

 

Code( ) showed some obvious differences between the two strings

Well, the two strings in your original post seem identical, so you should examine this in detail - character by character, if necessary.

Link to comment
Share on other sites

  • 4 weeks later...

 Is what a recent change? Some functions being case-sensitive and others not? No, that goes way back.

 

I meant has something changed recently with the way that copy and paste works between FM13 and previous versions of Filemaker.  The code snippet in question has survived 4 major releases of Filemaker without issue, but with the update to FM13 all of a sudden I'm finding differences in text strings that to the human eye appear similar yet for some reason contain dissimilar code characters.

Link to comment
Share on other sites

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