Toggle ( )

Function stats

Average user rating
257
317
9999
Support
FileMaker 10.0 +
Date posted
09 September 2011
Last updated
09 September 2011
Version
Recursive function
No

Author Info
 wirelessmac

1 functions

Average Rating None

author_avatar



 

Function overview

Prototype

Toggle  ( Boolean )


Parameters

Boolean  


Description

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.

Examples

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 http://www.fmfunctions.com/fid/317

    Prototype: Toggle( Boolean )
    Function Author: wirelessmac (http://www.fmfunctions.com/mid/257)
    Last updated: 09 September 2011
    Version: 2.0

*/
// ===================================

 

Comments

comment
09 September 2011



How about =
not Boolean
(Edited by comment on 09/09/11 )
  General comment
wirelessmac
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  (31)
Date  (26)
List  (26)
Format  (23)
XML  (22)
Sql  (18)
Dev  (18)
Debug  (15)
Interface  (13)
Text  (13)
Layout  (12)
Variables  (12)
Filter  (10)
Design  (10)
Layout Objects  (8)
Timestamp  (7)