Toggle ( )

Function stats

Average user rating
FileMaker 10.0 +
Date posted
09 September 2011
Last updated
09 September 2011
Recursive function

Author Info

1 functions

Average Rating None



Function overview


Toggle  ( Boolean )




Tags:  Interface  

This function simply toggles the boolean value passed in. If 1 is passed in then 0 is returned. If 0 or "" is passed in then 1 is returned. It can be used to toggle the state of global variables that you may have set up as flags or preferences in your solution.

In this way you can reproduce the functionality of a checkbox button more elegantly by making the associated text clickable, like it is in the OS.

Create a global number field called Pref_ShowWelcomeScreenAtStartup and place it on a layout. Resize it to the size of a standard checkbox. Add a check box list to it which has a single value in it of 1. Add text on the layout next to the field to say "Show Welcome Screen at Startup". Select the field and the text and define a button that uses the script step SetField to place the value returned from Toggle(Pref_ShowWelcomeScreenAtStartup) into the field Pref_ShowWelcomeScreenAtStartup.


Sample input

Toggle(1) = 0, Toggle(0) = 1, Toggle("") = 1

Sample output

Toggle(Pref_ShowWelcomeScreenAtStartup) = 1 if the field Pref_ShowWelcomeScreenAtStartup contains 0


Function code

not Boolean

// ===================================

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit

    Prototype: Toggle( Boolean )
    Function Author: wirelessmac (
    Last updated: 09 September 2011
    Version: 2.0

// ===================================



09 September 2011

How about =
not Boolean
(Edited by comment on 09/09/11 )
  General comment
09 September 2011

Even better, hardly worth making a custom function for except for the fact that it might read slightly more intuitively in your code, thanks for the comment.
(Edited by wirelessmac on 21/12/11 )
  General comment
Andries Heylen
21 December 2011

or simply as autoenter: GetAsBoolean ( self )
  General comment






Top Tags

Text Parsing  (33)
List  (32)
Date  (28)
XML  (27)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (13)
Filter  (12)
Layout Objects  (11)
Design  (10)
Array  (8)