-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added compareLists #14
base: master
Are you sure you want to change the base?
Conversation
compare listA vs listB for allowed values
Bob, thanks so much for contributing. This is exactly what I had hoped would happen as people become familiar with git/github and start using the filemakerstandards collection of CF's. With regards to this particular function, I'm left wondering if it's really needed. The semantic naming of the function may contribute to making code more readable, but the functionality of the CF is pretty much Filter ( ~selected ; ~allowed ). The simplicity of the code can easily be accomplished with IsEmpty ( Filter ( ~selected ; ~allowed ) ) for a boolean result. I'll let others on the list weight in on this viewpoint. One other thing I would mention is putting 'list' based functions within a List* collection. Such as ListCompare, ListExclude, ListCombine, etc. We do this with Value and other groupings of functions. |
Also, did you mean to use Filter or FilterValues() ? |
Hi My thinking on this came from integrating magento with our database and enabling multiple stores. As I have relationships to say that a product can be in website 1 and 2, but only in store 5 , 7 and 9 I needed a way to check I did not have any incorrect numbers in either the stores or the website field. We have value lists, based on the relationships, and then checkboxes to select the website and store The trouble with filemaker is that if you select the stores in different orders, the field can contain 3 1 2 / 1 2 3 / 2 1 3 etc. Product is in Website 1 and 2 so has the possibility of being in stores 1 2 3 4 5 6 (thats not to say it will be in all stores) Product is then removed from websites 1, so stores 1 2 3 are now invalid. (and so the value list for selecting the stores changes - however, it leaves the data in the field but the checkboxes look ok to the end user) Essentially, this allows us to check if the values are correct, regardless of their order and it works in both directions I hope that makes sense! Cheers Alex |
Bob, can you compare the custom function you are actually using in your database with the file in your commit? Like Matt said, I think you meant to use the FilterValues function instead of just Filter. I think the standard for a function like this is to return a boolean value rather than a text value. I also think the function name is ambiguous. Something along the lines of ListsContainSameValues is clearer. When it's just called "compareLists", how are you supposed to know what type of comparison is being performed? |
Hi Dan I'll take a look , and yes I agree the name is possibly ambiguous. Maybe something like listContainsValidValues ? I can change it to boolean no problem, its probably a good thing to do and I'll update this in my solution as well. I'm not sure on the filter vs filterValues - I'll need to give it a check over as I wrote is a few months ago and would need to check my workings on different input variables! |
ok, function in my live copy was a boolean output - I've updated to this and added some more notes. If I user filterValues, I do not get the correct result for the output as I'm looking for checking that the values are an allowed combination Example being. Product is enabled in website 1 ~allowed list = 1 Output = 0 - all match ~allowed list = 1 Output = 1 - error, the selected list has an invalid value in Example 2: ~allowed list = 1 3 ~alloed list = 1 3 Could possibly change the logic round ? for 1 = ok, 0 = error ? |
I think, as the function is named and described, it should be using FilterValues instead of just Filter. In your use-case, the values only contain a single character so it hasn't mattered which function was use. I think what you meant to write was this: https://gist.github.com/dansmith65/8249869 |
compare listA vs listB for allowed values
This will check to see if a Value is in the both lists and therefore a match - useful for checking if store ID's etc exist in magento - may be useful for your collection.
Alex