Jump to content
  • entries
  • comment
  • views

When to think about abstraction




Overview of when it would be beneficial to use abstraction in FileMaker

Sometimes you can benefit from a method called abstraction where you use what’s called “indirection.” Indirection is a way that you can automatically iterate through a series of steps like set variable or set field.

For instance, let’s say you needed to bring the contents of one set of fields in a table and create new related records in another, a process very common when dealing with legacy app data after importing it into a new app.


Here there may be quite a few fields. In this particular instance there happened to be about 40 and it’d be quite the pain to go through and manually copy the same block of script steps in order to create the new related records in order to set the fields, but if you look at the variable naming that is being done for each field set you can see that it follows a pattern of $document, $documentName and $documentNote followed by a number. Since it follows a known pattern like that, we can simply use a count in a variable to use the same loop to set all three fields which in this case looked like this:


Using the Evaluate() function we can ascertain whether or not there’s even a value in the $document variable by using a combination of $document & $count as the parameter. So, for the first time the loop runs we’re looking at the contents of $document1. The second time it’s $document2 and so on. So, once we’ve determined that we have a value in the $document variable we proceed to create a record and set the fields using the same technique of Evaluate() and their respective corresponding variable names.

It sure beats writing out or copying then tweaking 40 blocks of set field AND saves us a bunch of time to boot!

In what ways have you used abstraction or indirection in your apps?

The post When to think about abstraction first appeared on MainSpring.

Afficher la totalité du billet



Recommended Comments

There are no comments to display.

Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...