merkaba22 Posted November 29, 2005 Posted November 29, 2005 I want to enforce a field, IB_filename, only when another field, cat_calc, has a specific value, in this case: "Info Board". When I use this calc for field validation (following the correct naming convention) and cat_calc is not "Info Board", the enforcement is still applied-- any clues would be greatly appreciated:) If( cat_key; "Info Board"; Left ( IB_Filename ; 3 ) = "IB_" and Length (Filter (Middle (IB_Filename; 4 ; 99) ; "0123456789" )) = 3 and Length (IB_Filename) = 6)
LaRetta Posted November 29, 2005 Posted November 29, 2005 It looks good except: If( cat_key; "Info Board"; ... should be ... If ( cat_key [color:red]= "Info Board" ; Left...etc With your calc, you are asking FM "If Cat_key" Answer? Well, ummm, yes. It's like stating "I am therefore I am". But WHAT is it? You have no finish to your test. This question (of the syntax) would be fine if it was a number and you were boolean testing. But it's a text field and you are telling the calc that the ANSWER to that question is "Info Board". So by having the semi-colon where it is (between two parts of the test1), your Filter() portion is the default result ALONE ... without the "Info Board" test at all ...
merkaba22 Posted November 30, 2005 Author Posted November 30, 2005 LaRetta you beautiful girl:) SO ..... can we take this baby one step further? What if I want to enforce the field under different cat_calc values? If( cat_key = "Info Board"; Left ( firstslot ; 3 ) = "IB_" and Length (Filter (Middle (firstslot; 4 ; 99) ; "0123456789" )) = 3 and Length (firstslot) = 6) or (cat_key = "video"; length (firstslot) = 7)) for example?
LaRetta Posted November 30, 2005 Posted November 30, 2005 Would you be so kind as to write it out with each 'passing validation' as a separate line, even if you duplicate it? Something like: cat_key = "Info Board" AND Left ( firstslot ; 3 ) = "IB_" AND Length (Filter (Middle ( firstslot ; 4 ; 99 ) ; "0123456789" ) ) = 3 OR Cat_key = "Video" AND Length (firstslot ) = 7 OR ...etc Once you have each 'piece' listed that should pass validation, we can write the calc. One should NEVER even begin writing the calc until the logic is clear. And I can't tell from your calculation which piece goes with which validation. Make sense? Forget the parentheses and syntax ... just list it as regular words; using AND to group the different criteria and using OR to list each different group. One example of a break here ... or (cat_key = "video"; length (firstslot) = 7)) This is a separate validation because you are using OR. But you are saying, " If cat-key = "video" then produce the result of Length ( firstslot) = 7. So does cat_key need to = "Video" AND the length of firstslot need to be 7? AND produces results based upon all items (like a list). OR will start a new list for you. Make sense? Oh ... and because I wasn't clear on your calc, I missed one also. I had listed: It looks good except: If( cat_key; "Info Board"; ... should be ... If ( cat_key = "Info Board" ; Left...etc ... but I think you meant: If cat_key = "Info Board" AND Left (firstslot ... Each OR list must begin afresh. If you want Flower = "Rose" OR Flower = "Tulip" and both must Color = "Red", you must list them as: Flower = "Rose" AND Color = "Red" or Flower = "Tulip" AND Color = "Red" To FileMaker, semi-colons and commas are not writing sentences ... With a sentence, one writes: A Rose, tulip, daisy and carnation or a box of candy. FileMaker requires: Rose AND tulip AND daisy AND carnation OR box of candy. This is why it's good to list the logic first; either on paper or whiteboard or by using Let() and naming each piece as you go. It helps get the logic clear. I'll help you through it. LaRetta
merkaba22 Posted November 30, 2005 Author Posted November 30, 2005 I get it thanks. Sorry I have been unclear. The logic is that "firstslot" can receive varied values and the object of this calc is to have differing validations, each according to the value of cat_key, say, "Info Board" or "Video", for example, at the time. If the value for "firstslot" is considered with "Info Board" in the cat_key field, I would like validation along the lines originally discussed. However, if the value for "firstslot" is considered when "Video" is the value for cat_key, I would like the validation to be: Length ( firstslot) = 7. So: If( cat_key = "Info Board"; THEN validate by this calc: Left ( firstslot ; 3 ) = "IB_" and Length (Filter (Middle (firstslot; 4 ; 99) ; "0123456789" )) = 3 and Length (firstslot) = 6) or IF (cat_key = "video"; THEN validate by this calc: length (firstslot) = 7)) or IF etc. I hope that is better and I will make sure I am much clearer about what I am doing in the future. Thanks again -- you are great:)
LaRetta Posted November 30, 2005 Posted November 30, 2005 You explained yourself very well - nothing to apologize for. And you also just wrote your own calc. All you want to list are true values. Validation is a boolean test. Try: cat_key = "Info Board" AND Left ( firstslot ; 3 ) = "IB_" AND Length ( Filter ( Middle ( firstslot; 4 ; 99 ) ; "0123456789" ) ) = 3 AND Length ( firstslot ) = 6 ) OR cat_key = "video" AND Length ( firstslot ) = 7 Sometimes if I sound like a school marm, it's because I'm a User trainer. And I never know what someone knows, so I tend to give too much information rather than too little. If you need anything further, just let us know! LaRetta
merkaba22 Posted November 30, 2005 Author Posted November 30, 2005 (edited) You're the best -- I am self taught and owe so much to you all:) Thanks for everything. Edited December 1, 2005 by Guest
merkaba22 Posted December 1, 2005 Author Posted December 1, 2005 Well -- I thought we got it and now that I have had time to check it out, its not working as expected. I created a new field, second slot, with "always validate" by calculation with message: cat_key = "Info Board" and Left ( secondslot ; 3 ) = "IB_" and Length (Filter (Middle (secondslot; 4 ; 99) ; "0123456789" )) = 3 and Length (secondslot) = 6 or cat_key = "SID" and Left ( secondslot ; 4 ) = "SID_" and Length (Filter (Middle (secondslot; 5 ; 99) ; "0123456789" )) = 4 and Length (secondslot) = 8 or cat_key = "Artist Feeds" and Left ( secondslot ; 3 ) = "AF_" and Length (Filter (Middle (secondslot; 4 ; 99) ; "0123456789" )) = 3 and Length (secondslot) = 6 "Secondslot" appears in "Info Board" and "SID" and "Artist Feeds" with validations as above and works correctly ... thank you; yet, there are other layouts where I have no validations for "secondslot" yet I get an error message for a secondslot convention which will not resolve even if, as expected, the conventions for secondslot are followed -- how can I make this: IF AND ONLY IF: cat_key = "Info Board" THEN Left ( secondslot ; 3 ) = "IB_" and Length (Filter (Middle (secondslot; 4 ; 99) ; "0123456789" )) = 3 and Length (secondslot) = 6 or IF AND ONLY IF cat_key = "SID" THEN Left ( secondslot ; 4 ) = "SID_" and Length (Filter (Middle (secondslot; 5 ; 99) ; "0123456789" )) = 4 and Length (secondslot) = 8 or IF AND ONLY IF cat_key = "Artist Feeds" THEN Left ( secondslot ; 3 ) = "AF_" and Length (Filter (Middle (secondslot; 4 ; 99) ; "0123456789" )) = 3 and Length (secondslot) = 6 So that secondslot in layout "Videos", for example, is not enforced in any manner? Thanks:)
merkaba22 Posted December 2, 2005 Author Posted December 2, 2005 I think I got it ... All I have to do for each of the remaining layouts is add some like: or cat_key = "video" and Length ( firstslot) ≥ 1
Recommended Posts
This topic is 7029 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 accountSign in
Already have an account? Sign in here.
Sign In Now