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:
- Make sure you’re using FileMaker Pro 20.2 or later
- Go into layout mode
- Choose “Layout Calculation…” from the Insert menu
- The Specify Calculation dialog will appear
- Enter the syntax for your calculation, e.g.,
"Hello " & Get ( UserName )
- 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…
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”…
And I think that’s enough for today.