Rewrite Downloaded Functions

There are thousands of downloadable custom function examples available on various websites. These can be enormous time savers and I encourage everyone to use them. However, when downloading code, it is often necessary and advisable to review and even rewrite the code.

Recently a reader contacted me about his confusion regarding a downloaded function that converted a number ( 9, 25, 175 ) into a text expression of years ( “Nine Years”, “Twenty Five Years”, “One Hundred Seventy Five Years” ) and asked if I could help make sense of it.

Too often, the functions uploaded to these sites are lacking in one or more ways. They tend to be poorly structured, putting too much focus on an onerous brute force approach to achieving narrow functionality rather than providing a flexible, efficient and readable piece of solid code.

Looking at the code quickly explained his confusion. The downloaded custom function was a total mess.

Figure 1: The downloaded custom function was a mess

I was able to quickly rewrite the code to perform the exact same functionality, textually formatting numbers from 1-999 into a text representation of years. The result was considerably shorter and far more readable.

Figure 2: The rewritten code is much easier to read

When using code provided by others, be sure you review it and understand what function(s) it performs and how it works. Usually you will need to restructure the spacing to make the code more readable. Often, you will also want to enhance the functionality.

If you get stuck understanding or improving a custom function you downloaded post your question in my Learn Filemaker Facebook group. If you need professional help with custom functions, please contact me at my company website: Write Track Media.