Older Entries »
August 15th, 2010

A portal is a window to a related table. When you create a portal, you define the related table and the number of rows to be shown. Besides some other options you can also decide, whether the portal shall have a vertical scroll bar. Unfortunately FileMaker does not offer a direct way to change this option during run-time.

The size of the portal – and therefore the number of rows – may change at run-time. This will happen when you set vertical autosize option for the portal. Changing the height of the layout window will also change the size of the portal. There is no FileMaker function to get the number of actual visible portal rows. Even with such a function, you can not turn off the scroll bar when fewer records are shown in the portal.

To overcome this problem, I wrote two custom functions. These functions and a invisible object create an effect that will hide the portal scroll bar when fewer records than available portal rows are shown.

Read more …

June 9th, 2010

As a developer you might need a timer in your database. In that case you might find this feature helpful. You can create timer, as many as you like. Use them for benchmarks, to log import and export times, or to keep track of user log-in times.

Stop Watch

Each timer works like a little stopwatch. You can …

  • start it,
  • stop it,
  • restart/stop it again,
  • read the elapsed time,
  • and reset/remove it.

This is accomplished with custom functions and a global variable:

  • timer( name; action )
  • param( key; value )
  • param.get( key; params )
  • param.delete( key; params )
  • $$timer

Read more …

April 20th, 2010

What is the simplest custom function with a purpose you can write in FileMaker?
The answer is a custom function with only one character – and that includes the function name and parameters.

The Power of One

My simplest custom function has only a name. And it is the shortest possible name, a single character. The character I choose is the underscore. The function does not expect any function parameters and calculates and returns nothing.

Function _( )
/* no content */

The custom function is so simple I had to add this comment here, otherwise my custom function box would look just odd.

Why is there no content in the function body? Or, a better question, what does the function do?

This function will return an empty string (“”). And this should give you a clue, how to use the function. You can use this function wherever you would use an empty string:

  • Check whether fields or variables are empty
  • Initialize or ‘delete’ variables
  • For Let functions returning nothing (used to set global variables)
  • For ‘optional’ parameters in custom function you do not want to fill
  • For evaluation expression to avoid excessive use of the escape character

This also explains why I choose the underscore for the name of this custom function. The underscore looks like a placeholder or something empty and therefore resembles best the purpose and meaning of the function.

Example of Use

Compare for empty value:

If( $value = _; ... )

Delete global variables and return nothing from a Let function:

Let( $$counter = _; _ )

Call a custom function with optional parameter and keep that parameter undefined. In this example the function myFunction expects three parameter, but the second and third parameter are optional and do not require any value. I cannot really skip these parameters in FileMaker, but with the underscore I can indicate, I do not assign a specific value to them.

myFunction( "Arnold"; _; _ )
myFunction( "Kegebein"; _; 1 )

Avoid excessive use of the escape character. Without my custom function you would have to use some escape characters. That makes it harder to read and understand the expression.

Evaluate( "Let( $$X = _; _ )" )
//--- Without the custom function:
Evaluate( "Let( $$X = \"\"; \"\" )" )

Almost no day goes by without me using this function.

April 6th, 2010

Working with random numbers in FileMaker

When you want random numbers, you can use FileMakers function random. It is a very simple function. It does not require any parameter and returns a number between 0 and 1. Of course, often the random numbers you are looking for do not belong to this narrow interval. You have to transform the value to match your target range.

random.interval

I wrote a little custom function to accomplish this transformation. The function expects two parameters, the lower (min) and the upper value (max) of the target interval.

random.interval( _min; _max )
Random * ( _max - _min ) + _min

This is very simple. But often you are looking for discrete values, like throwing some dice.

random.discrete

The next custom function will take care of that. As you can see, I do not only floor the random value. Because of the discrete nature of the return value, I adjust the interval limit accordingly.
This call will return the random values of a single die: random.discrete( 1; 6 ).

random.discrete( _min; _max )
Floor( Random * ( _max - _min + 1 ) ) + _min

Random is not Random

Be careful, though, with random numbers. In any real life situations random numbers are not evenly distributed. More often they follow a distribution called Normal distribution or Gauss distribution. The graph of the probability density function is bell-shaped. It has a peak at the mean, and is known as the Gaussian function or Bell curve.

Unfortunately, the FileMaker function Random returns only uniformly distributed random numbers. But mathematics offers a solution. There are actual multiple ways to convert uniformly distributed numbers to normal distributed numbers.
Read more …

September 28th, 2009

The basis of each computer operation is binary logic. Zeros and ones are transformed with simple operations into zeros and ones again. FileMaker is hiding its binary roots very successfully. Only now and then the user can catch a glimpse of it. Some custom functions use binary elements, e. g. Get( ActiveModifierKeys ). And of course you can build logical expressions for If and Case functions, using and/or/not operators, but every value is used as a single logical value. Every number different from 0 is taken as the logical value 1 (True). There is no difference between 1 and 999, for FileMaker both values are a logical 1.

Bitwise operation

I need bitwise opertion for my projects. You might run into the same situation, perhaps managing a collection of flags. Each bit represents a flag. To set flags or ready the status of one or more flags requires binary calculations. In that case you have to take whatever FileMaker has to offer and build the missing parts yourself.

I wrote some custom functions to provide basic logical operations: bit.not, bit.and, bit.or, and bit.xor. Two more functions complete the package; bit.isSet for bit testing and bit.bitset to display decimal numbers in their binary representation.
Read more …

Older Entries »