Using the Self Function
You got a peek at the Self function back in Figure 11-1. The Self function simply returns the contents of the object it’s applied to. Without a Self function, you’d have to use the Object Info palette to name the object you wanted to format conditionally, and then reference the formatted object by name in your calculation. But that’s just too much work, so FileMaker’s engineers created the Self function to make that process easier. The good news is that you can use the Self function in your own calculations to make them portable—that is, you won’t need to retrofit them if you move them from one field or object to another.
Here’s one example of how it works. The five volunteer data entry folks keeping up with your theater group’s subscription and donor list are expressing their artistic temperament by using different formats for phone numbers. So when you print out the contact list, you’ve got (800) 555-1212, 800-555-1212, 800.555.1212, 555-1212, and every other variation under the sun.
FileMaker’s Auto-Enter calculations can help you transform self-expression into standard formats. To straighten things out, you could add this calculation to your Phone field:
"(" & // start with an open paren sign Left ( Filter ( Phone ; "0123456789" ) ; 3 ) & // grab the area code ") " & // finish the area code with a close paren Middle ( Filter ( Phone; "0123456789" ) ; 4 ; 3 ) & // grab the exchange "-" & // give me a hyphen Middle ( Filter ( Phone ; "0123456789" ) ; 7 ; ...
Get FileMaker Pro 9: The Missing Manual now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.