Make it readable

The coding style guidelines on this site are intended to increase the clarity and readability of your FileMaker code. Careful consideration has been given to the fact that it's all too easy to simply "code-n-go" within FileMaker's calculation dialog box. The information on this site is not here as an imposition. It offers a structure which provides liberation from future mental processing.

As of current, FileMaker does not provide a "code editor" inclusive of beneficial features such as syntax highlighting, code completion, block disclosure (for hiding segments of code) and code checking using a linter. Therefore, it is up to the developer to compose clean code which can easily be read not only by the primary developer but anyone else who may need to make sense of what was done.

The current tools available to FileMaker developers include external editors and snippet or keyword expansion tools.

The following is a very simple example of unreadable vs. readable code. This is a very common example of a FileMaker calculation used to provide user feedback such as a message - either within the user interface or some form of output. The goal is to identify if the current customer is tagged within the category of "prospect" and show a message accordingly.

Unreadable code

Let ([ CustomerPhone = Customers::phone ; Categories = List (Customers::Categories) ; Name = Customers::FirstName & " " & Customers::LastName];
If ( PatternCount ( "¶" & Categories & "¶" ; "¶prospect¶" ) ; "Please contact " & Name & " at " & Customers::Phone ; "" ))

Readable code

Let ( [
	~customerName = Interface » Customers::firstName & " " & Interface » Customers::lastName;
	~customerPhone = Interface » Customers::phone;
	~categories = List ( Interface » Customers::categories );
	~categoryMatch = "prospect"
];
	If ( PatternCount ( ¶& ~categories &¶ ; ¶& ~categoryMatch &¶ ) ;
		"Please contact the " & ~categoryMatch & " " & ~customerName & " at " & ~customerPhone
	)
)

Things to note about the code above

All of these types of visual clues contribute to code that is considered "elegant" and easy to read.

Key objectives

 

If you currently have messy code and want a head start on code cleanup you can use this tool FileMaker Calculation Formatter. While it does not adhere to the standards outlined here. It does a lot of the hard word for you.

It is assumed that, as a serious FileMaker developer, you are using FileMaker Pro Advanced with access to custom functions and other advanced features. Taking full advantage of FileMaker requires this investment.