Jump to content

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

Recommended Posts

Posted

I think I've done my first calc, without help! grin.gif Okay, okay, I think it's a pretty easy one, but it still feels good! But I want to run it by the forum to make sure there's nothing I'm missing ... if I'm wrong, LOTS of billing could be rejected.

I have a CGAS score that must be between 30 and 65. So I created field, number, validation by calc:

Case( CGAS >= 30 and CGAS<= 65, CGAS), strict do not allow override, index off but turn on if needed. It appears to work. It doesn't allow me to enter outside the range, only allows me to 'revert' the field if I'm wrong, but does accept numeric changes within the range. Is that right? smirk.gif

Posted

Hi LaRetta,

Well done! smile.gif - what you've done is fine and will work!!

The only point to note is that validation calculations are expecting a boolean result (0 for not valid, 1 for valid). Since the way FIleMaker words is that all non-zero values are regarded as valid, putting the CGAS field itself in for the case result works. However, you only actually have to have the code return a 1 or a zero, so a slightly simpler formulation, which would achieve the same outcome would be:

Case( CGAS >= 30 and CGAS<= 65, 1)

And the most efficient way would be to dispense with the case statement altogether. Since tests themselves produce a boolean result, all you really require to get the validation working is the expression:

CGAS >= 30 and CGAS<= 65

In the interests of efficiency, you might want to make the change to the shorter/simpler form of the formula, but it will be no more accurate than the syntax you have in place now.

Posted

This is very interesting, I'm a bit confused however. The result that needs to reside in the numeric field is a two-digit number. Now, I'm a bit short on sleep and am probably misunderstanding (although I read it three times, right now, that doesn't mean much), are you suggesting that FM will insert a '1' in the field? Could you explain just a bit more for me, Ray? crazy.gif

Posted

It also relies on the fact that Case, if it has no default result, will return "empty" AND that an empty value will be interpreted as a false boolean value. Given the programmer that may follow you someday (including yourself) may be bewildered by why the Case and what fiendish reason must've existed for it... I would recommend changing to the latter formula that Ray suggested.

Posted

We are both assuming by your title that this is NOT the calculation of the field, but rather the calculation that you entered into the Validation section of the field. Right?

Given that, the job of that calculation is NOT to compute the value of the field. Rather, the job of that calculation is to return true (1) if the value the user input into the field is valid and false (0) if not. That way, whenever someone types in a value, FMP will automatically consult your calculation to determine if it is valid.

As another example, you could check the "max number of characters" validation check and input 7. That would be equivalent to checking the by calculation flag and inputing the formula "Length(MyField) <= 7". Both are simply answering the boolean question, "Is what the user just input a valid value for this field?"

Posted

YES! Yes, I see it -- Thanks Brian for explaining it! Validation is boolean -- I really like this!! I tried Ray's last formula (and yes, I ALWAYS prefer the shortest, simplest formulas) and it worked exactly the same! Validation is boolean, 1 or 0 yes or no -- I think I'm going to like formulas once I start really understanding what I'm doing grin.gif And, YES, Ray my left-brain is tickled on this one!

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