Brian Dunning's FileMaker Custom Functions

SetVar ( InValue )

Assign value to a variable, making sure variable exists if value is empty.

  Average rating: 4.9 (14 votes) Log in to vote

Richard DeShong   Richard DeShong - Show more from this author
Logic Tools
http://logictools.com

  Sample input:
SetVar ( "test" )
SetVar ( "" )
  Sample output:
"test"
"Empty"

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This is complementary to the SetField() function.
Both SetField() and SetVar() use the text string "Empty" to indicate no value.

The idea is, when I set variable, I want the variable to exist. But if the source data (such as a field) is empty, then FM does not create the variable. Of course, you can use IsEmpty() to test, but I prefer to be able to see the variable in the Data Viewer. So SetVar() sets the variable to "Empty" if the source has no value. And SetField() understands that it should return "" if the variable is "Empty".

Example:
If a field, table::MyField, is empty, and I use SetVar(),
$MyVariable = SetVar( table::MyField )
Then $MyVariable is now = "Empty".

SetVar() and SetField() are used in LIST functions, which are designed to work with variables and the "Empty" idea.
ListAdd(), ListAddUnique(), ListExist(), ListGet(), ListToggle().

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 21 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: