I recently moved to OS X Yosemite, and once again repeated the annual cycle of wondering whether or not my existing solutions will be compatible with the new version. I’ve loved using AppleScript to trigger OS X Notifications from FileMaker since they were introduced in OS X Mavericks, but they stopped working as soon as I installed Yosemite. I still check system version so I can show a FileMaker Custom Dialog for users who don’t yet have that feature. But Yosemite’s version number broke my check!
Yosemite = 10.10.x and Mavericks = 10.9.x
The version “numbers” returned by Get ( SystemVersion ) are actually text data, technically speaking, so “10.10.1” is actually less than “10.9.5”. Just think about how alphabetical sorting treats this: The first “letter” 1 matches from both strings, so we move on to check the second character 0, which also matches for both strings, and the third, until we get to the fourth “letters” 1 vs. 9. 1 is less than 9, so “10.10.1” is less than “10.9.5”!
The problem is that we think of the three decimal-separated components of the version number as distinct sub-sorts, whereas FileMaker thinks of each string as one blob of text. Fixing the issue isn’t just as simple as wrapping the version numbers with the GetAsNumber function, either. If you use GetAsNumber ( Get ( SystemVersion ) ) it will drop the last decimal point, and it will still treat all three components of the version number as one:
Yosemite = 10.101 and Mavericks 10.95 — Mavericks still wins!
Our custom function master Will Baker wrote this custom function to address this issue.
Let ( [
systemVersion = Get ( SystemVersion ) ;
componentList = Substitute ( systemVersion ; "." ; ¶ ) ;
majorNumber = GetValue ( componentList ; 1 ) ;
Right ( "00" & GetValue ( componentList ; 2 ) ; 2 )
& Right ( "00" & GetValue ( componentList ; 3 ) ; 2 )
GetAsNumber ( majorNumber & "." & minorNumber )
NAME: GetSystemVersion ( )
PURPOSE: Return System Version as a numeric string, even if there are two decimals in it.
2015-01-07 14:20 PST - Will M. Baker. Created.
This function forces the secondary and tertiary components of the version number to use 2 digits each so that “10.1001” is greater than “10.0905”. Here is what the corrected script looks like, and now notifications come through again!