FM Function of the Week: GetContainerAttribute

New in FileMaker 13, and previously fawned over in this very blog, is the GetContainerAttribute function. Prior to this, when you dropped a file in a container field, you had few options for getting information about it. There wasn’t even a foolproof way to determine what kind of file was in there. Imagine setting up a container field for storing audio only to find out later that people had been dumping images and spreadsheets in there. You just had to hope everything was being used as intended.

With the advent of GetContainerAttribute, we can now reliably get the name, size, and a few dozen other bits of info about the contents of a container field. But let’s start with the fundamentals.

GetContainerAttribute ( field ; attribute )

To invoke the function, two parameters are required inside those parentheses. First is the name of the container field. If you point the function at a non-container field, the function will fail and simply present a question mark for a result. The second parameter is the attribute you wish to obtain. It’s important to put the attribute name in quotes or FileMaker will think you’re referring to a field here.

 

GetContainerAttribute ( myField ; "filesize" ) = 2048

So let’s suppose I’ve placed a 2 MB file into a container field cleverly named “myField”. Using GetContainerAttribute ( myField ; “filesize” ), FileMaker will inform me that the file in that container is 2,048 bytes in size (which is the same as 2 MB).

FileMaker’s on-screen help has a complete listing of the attributes that can be invoked, but a few of my favorites are below.

MD5
Besides being my new DJ name, MD5 is a kind of numerical fingerprint based on the content of the file. By comparing the MD5 value of two files, you can determine if they have the same content regardless of files’ names or modification dates.

Latitude and Longitude
Most smart phones and many cameras can embed the device’s current GPS coordinates at the moment each photograph is taken. This is commonly called geotagging. Drop a geotagged photo into a FileMaker container and you can pull the coordinates back out of the file to find the location using an online map. In fact, that’s just what I did in this example last year.

metamap01

Make and Model
If you’re ever curious about what kind of camera equipment was used to capture a photo, the Make and Model attributes can tease that out. This information is typically embedded at the time a photo is taken with a smart phone or digital camera, but it’s not magic. You can’t scan your great grandfather’s 1922 portrait to find out if it was taken with a Kodak Box Brownie camera.

CoverArt
MP3 and M4A audio files have the ability to carry a small image file as part of their metadata. Indeed, most music you purchase for download now comes with the artwork for the single or album baked right in. GetContainerAttribute has the ability to extract the image from the sound file and place it into another container field for display.

Signed
When using FileMaker Go to capture signatures, a timestamp (the date and time down to the second) is saved along with the autograph. Run the Signed attribute against a field with a signature and you can know just when it was penned.

This entry was posted in FileMaker 13, Function of the Week. Bookmark the permalink.