Level: Intermediate, Version: FM 20.2 or later

Layout Calculations in FileMaker 20.2

The recent release of FileMaker 20.2 introduces a feature that developers have long been asking for: the ability to define calculations at the layout level without resorting to workarounds (such as those we saw in Button Bar Segment Fun, part 1 and part 2.)

You can read the official word(s) from Claris here…

…and today I just want to share a few observations. First, in case you haven’t yet gotten your feet wet with layout calculations:

  1. Make sure you’re using FileMaker Pro 20.2 or later
  2. Go into layout mode
  3. Choose “Layout Calculation…” from the Insert menu
  4. The Specify Calculation dialog will appear
  5. Enter the syntax for your calculation, e.g.,
    "Hello " & Get ( UserName )
  6. Click OK

You’ll see something like this in layout mode…

…and this in browse mode (if your user name happens to be Kevin).

Okay… let’s go back into layout mode for some experimentation. If you control-click on the layout calc block you can access the Specify Calculation dialog…

…but, if you prefer, you can also edit the layout calc directly on the layout.

Note that you can resize the block to hide some of the syntax…

…but be sure to leave enough space for the result to fully display in browse mode, taking into account of course that UserName could be lengthy. The block will not auto-expand to display its full contents so you need to size it accordingly.

As with merge text and merge variables, the formatting lives in the first character so you have the option of reducing subsequent characters to a smaller point size (or different font) if you are so inclined… though, given the preceding (that you can instead reduce the text block size), it’s not clear to me there is any compelling argument for doing so.

Can you include multiple layout calcs in a single text block? Sure; let’s re-code the above example to use two layout calcs.

And here it is in browse mode.

Note that if you code the block this way, and then subsequently control-click the block and choose Edit Layout Calculation, you will only have access to the first layout calc in the block.

But if you instead highlight the subsequent block and then control-click it, the corresponding syntax will appear in the Specify Calculation dialog.

Actually you don’t even need to highlight the layout calc syntax; clicking within the relevant layout calc and then control-clicking will suffice.

And note that having done so the corresponding syntax will be highlighted in the source block.

So far we’ve been looking at layout calcs defined via Insert > Layout Calculation. But assuming you are in layout mode, you can also enter them directly onto a layout via the Text tool by typing…

<<ƒ:CALCSYNTAX>>

If you’re on a Macintosh you can generate the italic f via option+f. You can do the same in Windows via Alt+0131 on the number pad, or, on either platform, by copying/pasting Char(402) from the data viewer.

In closing here are a couple more thoughts on Layout Calculations…

#1. As you may know, FileMaker does not allow merge variables where the rep # is greater than 1. (Note that I said variables; merge fields are not restricted in this way.) Well that restriction can now be bypassed like so: <<ƒ:$$var[rep]>>

For example, given this Let statement…

This does not work…

…whereas this works just fine:

#2. For a very long time FM developers have been wishing for a simple way to define buttons with calculated labels. Well thank you Mack Richardson at Codence for pointing out that we can now enter layout calculation syntax into button labels. Assuming $$user = “Mack”…

Layout Mode

Browse Mode

And I think that’s enough for today.

 

4 thoughts on “Layout Calculations in FileMaker 20.2”

  1. Thanks for that, Kevin. One thing I’d like to add: the ability to resize a text block with merge text in it (to make the text object smaller than the enclosed text) is not limited only to layout calculations. It’s also now possible to put a merge field with a very long name onto a layout and shrink up the text block to fit the available space, without resizing the text down to 4 point (or whatever). IOW, we no longer have to worry about the formatting keying off the first character of the merge text. That whole “text objects can’t be made smaller than the text they contain” issue is a thing of the past.

  2. One thing to point out is when exporting layouts with calculations, the calculations don’t get exported when using Export or Save As dialogs.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.