Jump to content
  • entries
    69
  • comment
    1
  • views
    2042

Reviewing the GetLayoutObjectAttribute function in FileMaker


MainSpring

240 views

 Share

This versatile function offers quite a bit of value to any developer’s toolkit. It gives us the ability to interrogate the state of different layout objects (also called introspection) which allows us to make our calculations and scripts smarter. Today we’re going to just focus on a one of the options, the attributeName parameter to take a look at some interesting behavior that could be leveraged as another tool in our developer toolbelt. 

Parameters

objectName – in order to use this function, the object to be interrogated must have a name set in the position tab of the inspector. I prefer to use the naming convention of “objectType.name” for clarity. 

f1.png

attributeName – the name of a supported attribute specific to the type of the layout object. Which we are using the “content” for this example.

Persistent local variables

It’s possible to create local variables without running a script. Here you can see the layout we have some text describing the function:

f2-1200x997.png

Going into layout mode you can see that these are all merge variables placed on the layout, but they are all local variables which normally only exist as long as a script is executing

f3.png

However, the only script in the file has no set variable steps

f4-1200x901.png

This is accomplished by utilizing the “Hide object when” calculation in the data tab of the inspector for layout objects in tandem with the content option for the attributeName parameter of the function.

f5-1200x287.png

Off to the side on this layout we have a text object with a calculation

f6-1200x538.png

This works because when FileMaker is loading a layout it has to check the hide object when calculation for each layout object to determine if it displays or not.  Here we’re using “Evaluate( GetLayoutObjectAttribute ( “text.display” ; “content” ) )”

Since we used a let statement to declare local variables as the content of our text object and wrapped it in an evaluate function FileMaker will instantiate the local variables even though no script has been run. Checking the data viewer’s watch tab, you can enter in one of the local variables and see that it contains a value but on the current tab the same variable will not be present.

Note that you can also set global variables using this same method.

These variables will persist until FileMaker is closed or explicitly removed through a set variable script step or through the watch tab in the dataviewer using something like Let() to set them to “”.

f7-1200x975.png

Uses

One use could be to dynamically alter the text sizes on a layout when the user alters the window size. Assuming we’re using the same technique here we can dynamically set the text size based on the size new window size. Since FileMaker redraws the layout on a window size change the hide object when calculation will be evaluated again and will update the sizes accordingly.

I’m excited to hear from you what you think you could do with this. Until then, happy FileMaking!

Download the Demo File


The post Reviewing the GetLayoutObjectAttribute function in FileMaker first appeared on MainSpring.

Afficher la totalité du billet

 Share

0 Comments


Recommended Comments

There are no comments to display.

Guest
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.

Loading...
×
×
  • Create New...