ISO FileMaker Magazine: FileMaker Video Tutorials, Templates, Help & More

Navigation

Video Browser

Scriptology Video Browser

Tools & Resources

IsValid

IsValid( "BruceWillisBaldness" )

Posted by: aflgenx / Sunday, August 19, 2007 – 5:32am

So I haven't blogged in the while - been busy with something i'll tell "you's all" about later. As I was sitting there I thought, what better reason to blog than to try and reason out why Bruce Willis is as bald as he is. Well, I was going to but thought Matt might get upset... so instead this post will breifly discuss data types and how the IsValid() function mixes it all up (a bit of a let down i know :p ).

The thought to write about this came from an auto update plugin ... article type thing... at Six Fried Rice recently - love these guys and somehow, they get their posts to flow in more of a straight line than mine. Anywho, it's a bit of a weird function and while it may be obvious to some, its workings can often escape logical reasoning for no logical reason.

Now, the purpose of IsValid() is to determine whether the contents of a data container (i.e. a field or variable) match the data container's data type. With fields this is farily obvious:

How It Works with different Data Types:
1) Text - Essentially it will output valid for everything..
2) Number - Will output false if a text string alone is present in the field i.e. "abc" will return 0, while "abc1" will return true.
3) Date - Will output false for any non-conforming date (example in MM/DD/YYYY) 18/3/2007 will be rejected -- one of the more useful options
4) Boolean - Outputs valid pretty much always.
5) Container - Like text, not really useful... unless you skip validation somewhere.

Now with fields where the data type is already defined, it really has little use in most cases, so when do you use it?

One potential place is scripts. Think date inputs into a custom dialog, you don't want to manually have to validate this sort of stuff or worse yet let it slip past: IsValid( GetAsDate( input ) ) is your functional statement (*note to self: don't make up terms*). GetAsDate( input ) immediately tells IsValid() that you are checking for the validity of the contents of the input field using the date data type - IsValid( GetAsDate( "17/17" ) ) for example, returns false.

Now - here's where a lot of people slip up, data type conversion can happen relatively unoticeably in various places in FileMaker. The most common form though is concatenation - concatenate something and it immediately becomes a string.. i.e. text data type.

An interesting note about variables:
When assigned, they conform to the data type of the object to which they are being assigned. For example if number was a number field: Set Variable[$number ; Value: table::number ] would create a variable $number with the data type of a number. If $number was a variable that had been dynamically cast somewhere then Set Variable[$number2 ; Value: $number] would set $number2 to be a number type variable.

An interesting note about Script Parameters:
After a bit of experimentation, curiously enough, they are always passed as text data.. intriguing.

PS. Die Hard 4 = Awesome!!

By the way, feel free to leave comments if you want... seriously it'd be good to know if anyone's benefiting at all from my ramblings or how bad my speeling is ;) .

Filed under: |
Syndicate content

Be Notified!

Let us tell you when a new video is posted. We'll send you an email with a direct link right to your email inbox.
Make sure and whitelist (or add to your address book editor@filemakermagazine.com

Give your FileMaker interface a beautiful overhaul, make your layouts look great!Theme Box 150 Take control of your users' permissions using the Scriptology Permissions Template!Perms Box 150

iPod Video

Magazine IPod Small
Click to watch the video

FileMaker Reference Tool