# Functions of File maker - File Maker

Now that you understand the basics of putting together a calculation, such as how to use operators, how to make reference to fields, and how to enforce precedence, you can take a look at one of FileMaker’s most powerful features: its wide range of functions. Functions bring another level of tools to your calculation arsenal. They allow you to make conditional statements, so that if certain conditions are met, then one expression is used, and if other conditions are met, a different expression is used. They make some calculations simply easier. For instance, there’s a set of financial functions, which you could build from scratch using simply the mathematical operators, but using the functions makes your calculations much easier to build and understand.

Most functions use parameters: pieces of information that the function needs in order to compute its result. The form of the parameters is Function(parameters). For instance, one can’t compute the square root of a number without a number to use. In this case, the number you want to find the square root of is the parameter. Not all functions take parameters. PI is a function to FileMaker, but it needs no parameters, because you don’t need to know anything else to get the value ð from the computer.

Parameters can be any allowed expression that resolves to a value of the type that the function expects. Going back to the square root example, whose function is Sqrt, the function expects a number as its parameter. Asking for the square root of “John” wouldn’t make much sense. This number could be a constant, such as Sqrt(9), or it could be an expression such as Sqrt(5 + 4) or Sqrt(Area), where Area is a number field. Remember, an expression is just something that can be resolved into a value, and functions resolve into values, so the expression could include other functions, such as Sqrt(PI). Much of the power of FileMaker functions stems from this ability to nest functions, to take the results of one function and pass it as a parameter to another function.

Many functions take multiple parameters, and the number of parameters for some functions is limited only by the limit on the available size of the calculation (see Case and Choose for examples). When multiple parameters are required, they are separated by commas on most systems, although some systems will use a semicolon, depending on which country the system was set for when the database was created and whether “Use system formats” is on or off.

Given that many functions have multiple parameters and that functions can be nested, now is a good time to discuss formatting functions so that they are as readable as possible. One way to do this is to make good use of white space.

White space is extra spaces that help to format the look of the calculation but don’t alter the result. When you get to scripting, you’ll find that some script steps appear inside of control steps, such as when a script step should be executed only if a certain condition is met. The steps inside of the If block are indented to make it easier to tell which steps apply to that condition. You’ll find that it is helpful to duplicate this idea within calculations. Take a look at the following two calculations:

Case(My_Field=1, Left(Other_Field, Position(Other_Field, "¶",1, 1)+1,
Position(Other_Field,
"¶",1,2)),My_Field=2,Right(Another_Field,Length(Another_Field)- Position(Another_Field,"¶" ,1,PatternCount(Another_Field,"¶"))),Other_Field) and Case( My_Field=1, Left( Other_Field, Position( Other_Field,"¶", 1, 1 )+1, Position( Other_Field,"¶", 1, 2 ) ), My_Field=2, Right( Another_Field, Length( Another_Field) - Position( Another_Field,"¶", 1, PatternCount( Another_Field,"¶" ) ) ), Other_Field )

As far as FileMaker is concerned, these two calculations are equivalent. (Whether this is a useful calculation, which it probably isn’t, doesn’t matter.)

Which one is easier to read? Well, that’s a matter of opinion, but the second is probably at least easier to understand and troubleshoot. It’s much easier, for instance, to see in the second example that the Length function is a parameter of the Right function. Following these examples of functions, this is the convention you should use. Parameters will appear on separate lines, and they will be indented with spaces (two spaces for each level of indentation). The only time you won’t indent for parameters is when the function takes only one parameter, such as is the case with Length. Even when a function takes only one parameter, however, you should add some white space in the form of a space after the opening parenthesis and before the closing parenthesis. You should also add space before and after operators such as the plus and equals operators.

Of course, you don’t have to duplicate this technique, especially if it doesn’t work for you. The point to keep in mind is that the more complex a calculation is, the more difficult it is going to be to grasp if there is no white space, so the recommendation is to make use of white space in a way that makes calculations easier for you to read. The other thing to keep in mind is that whatever technique you use for increasing the readability of your calculations, be consistent. Don’t use one technique in one calculation and another in a different calculation.

Another convention used here is to show how calculations resolve. When you see a calculation and then the result, the result will appear below the calculation after the word RESULT in all capitals, like the following:

5 + ( 6 * 7 ) – 3 RESULT: 44

FileMaker divides the functions available into sections. You’ll learn bout each section and all of the functions that are available. The remainder of this discusses each function by name, the parameters it requires, and some examples and ideas of how it can be used

File Maker Topics