Older Entries »
August 28th, 2010

Working with Fonts

In the last few days I worked on my template database again. I use it as a storage place and work of reference of ideas, features, and solutions I developed with FileMaker. It includes a basic collection of custom functions, default scripts for trigger management, and design samples.

Designing a good looking layout is a challenge in itself. But when you try to use the same layout in both worlds, Mac OS and MS Windows, raises the challenge quite a bit. Main problems are the font. There are only few fonts available in both systems. But having the same name does not make it the same font. Text formatted in the same font might have different width and height – resulting in really ugly layouts.

There are different ways to redress these problems:

  • Oversize all labels and fields
  • Use conditional formatting
  • Use hidden tab controls for each operating system
  • Create separate layouts for each operating system

Often, you will use a mixture of different solutions. But to master these challenges you should know a little bit about the fonts in Mac OS and MS Windows.
Read more …

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 …

Older Entries »