Global Variable Checkboxes
As any FileMaker solution grows, you'll inevitably end up adding more and more settings. In some situations, these settings are simple toggle checkboxes which control how things function in the user interface. Either from a user or admin perspective, it really doesn't matter.
What does matter is having to manage all of the aspects of each of these settings. Granted, the easiest thing to do is simply add a new field and making it a checkbox - but, what to do when you know you're adding an extra field simply to control how something works within the user interface - while the solution is running. Does this UI field commingle with your schema? Do you separate it out into a user interface file and data file?
Of course, the answer to those questions depend on your solution and the implementation. In this video, I present a topic related to single value checkboxes and toggling those values. I've been using it as a solution to adding yet more scripts to my solutions. It's very easy to copy and paste the whole layout object and very quickly have a new control setting.
Comments
Global Check Boxes
Hello Matt: Very useful technique. I was intrigued by a feature you probably didn't notice in this demonstration. When the field label was clicked, it did not highlight. When I created an ordinary text field on your layout, the field boundaries highlighted when I ran the commit script from a button (rather than use a script trigger). I find the highlighting looks amateurish these days. However, I could not get a script trigger to work on a simple text field. Is there some trick I am missing here?
Bruce Drake
Bruce Drake
Ahhhh, this is a tweak
Because FileMaker 12 now uses CSS behind the scenes, I tweaked this particular button to not show the dimmed highlight.
Using my own Theme Studio product (in the Tweak tool), I set the CSS selector of background-color on the self:pressed setting of the button object to rgba(0%,0%,0%,0) - which makes the highlight not show.
There are many things you can tweak about objects such as buttons - but FileMaker has not exposed these things as of yet. However, they are fully supported because it is only a slight change between what is normally used and what you adjust it too.
You can find the tool here if you want to try it out for yourself.
http://filemakerthemes.com/downloads
-- Matt Petrowsky - ISO FileMaker Magazine Editor
Great function thanks but...
I am probably being naive here I cannot see anywhere that all the Global Variables have been set sucj as $$@TECHNIQUE.DESCRIPTION and the menu items. I am interested in these techniques but could not see any script that sets them - what am I missing please
Any of the $$@ variables...
Have nothing to do with the technique being presented. Those are used for the technique file itself.
All of those will make it seem more complex than it really is. The only global variables the technique file is changing is the one which is within the Go To Object step on the actual text label.
I was hoping the $$@ variables would not confuse people. :(
-- Matt Petrowsky - ISO FileMaker Magazine Editor
Oh...
If you are asking about how the $$@TECHNIQUE variables are set then look at the layout named Settings and the one named English.
They contain a single text object which is evaluated using conditional formatting. This cuts down on the the number of scripts and provides a single location to manage them.
I covered this is the previous video here.
http://www.filemakermagazine.com/videos/canonical-coding.html
-- Matt Petrowsky - ISO FileMaker Magazine Editor
Global check boxes
It would be helpful to me to see how the global checkboxes are actually used in a simple database file.
You can use global variables to control anything
Within the user interface. Here's an example. You have a database that allows you to send out email. You want to allow attachments. You provide a checkbox which controls the global variable $$HAS.ATTACHMENT which is either true or false.
Your script for sending email then has steps that read as such.
If [$$HAS.ATTACHMENT]
# Do other steps here
End If
Whether an attachment is a persistant setting in your solution or not is up to you - but in most cases it's a very arbitrary thing based on the email being sent.
Does this help out?
-- Matt Petrowsky - ISO FileMaker Magazine Editor
Thanks
This is very simple and very useful. :)
Extension of the technique idea
For preferences that relate to how a specific record is dealt with, not just a session wide setting-
I use an OnRecordLoad script to render the preference variables.
Then an additional OnObjectExit script on the preference button, (passing in the global variable), to save the toggle choice into it's storage field.
This way the same technique, look, and feel applies to both types of preferences.