Tim Dietrich

Custom Software Developer

Home Services Portfolio Blog About Contact Newsletter

fm.swift: A FileMaker-to-Swift Translation Class

Today I'm excited to share "fm.swift," a Swift class that provides functions that are similar to FileMaker functions.

fm.swift includes functions for many commonly used FileMaker text functions, including Length, LeftWords, MiddleWords, RightWords, Left, Middle, Right, Lower, Upper, Proper, and more. There are 14 functions in all, and I'm planning to add more functions in the future.

To use the class, simply include it in a Swift project, then call the functions by prefixing the function names with "fm." For example, you'd call the Length function like this: fm.Length("Hello, world.") Included below are examples of how to call the other functions.

You can download the class file (as part of a Swift project) here, or grab it on GitHub.

fm.Length("Hello, world.")
// 13

fm.Left("Hello, world.", numberOfCharacters: 5)
// Hello

fm.LeftWords( "First Middle Last Suffix", numberOfWords: 3)
// First Middle Last

fm.Lower("Hello, world.")
// hello, world.

fm.Middle("Hello, world.", start: 1, numberOfCharacters: 4)
// Hell

fm.MiddleWords( "First Middle Last Suffix", startingWord: 3, numberOfWords: 2)
// Last Suffix

fm.PatternCount("Mississippi Bliss", searchString: "iss")
// 3

fm.Proper("john doe")
// John Doe

fm.Right("Hello, world.", numberOfCharacters: 5)
// orld.

fm.RightWords("First Middle Last Suffix", numberOfWords: 2)
// Last Suffix

fm.Substitute ("Hello, world.", searchString: "Hello", replaceString: "Goodbye" )
// Goodbye, world.

fm.Trim(" This is a test. ")
// "This is a test."

fm.Upper("john doe")

fm.WordCount("This is a test.")
// 4