Get ( ApplicationVersion )
is the most obvious way to get the application version when you need to sniff out whether the user has the ability to use the latest feature or whether they should be warned about changes.
The gotcha is that the function returns locale specific information. My install is using New Zealand English and returns Pro 22.0.1
.
Also, the function returns the name of the client application and the version number. That is literally what the name says, so that’s ok. When you just want the version you’ll need to use Rightwords ( Get ( ApplicationVersion ) ; 1 )
. For me that returns 22.0.1
.
It would be nice to use Greater Than or Less Than to easily test the version but the version is not a number, it’s a string, so we have to split it into components and test each component.
Let( [
// sep = JSONGetElement ( Get ( FileLocaleElements ) ; "Num.Decimal" )
sep = "."
; ver = RightWords ( Get ( ApplicationVersion ) ; 1 )
; splitver = Substitute ( ver ; sep ; ¶ )
] ;
GetValue ( splitver ; 1 ) = "22" and
GetValue ( splitver ; 2 ) = "0" and
GetValue ( splitver ; 3 ) = "1")
)
We could make that into a Custom Function called GetVersionPart
and return the component we want to query, such as GetVersionPart[ 1 ]
.
/*
Returns the version part as a number
-- parameter: partnumber, must be in range 1 .. 3
*/
Let( [
// sep = JSONGetElement ( Get ( FileLocaleElements ) ; "Num.Decimal" )
sep = "."
; ver = RightWords ( Get ( ApplicationVersion ) ; 1 )
; splitver = Substitute ( ver ; sep ; ¶ )
] ;
if ( partnumber ≥ 1 and partnumber ≤ 3 ; GetAsNumber( GetValue ( splitver ; partnumber ) ) )
)
That’s nice, now we can say,GetVersionPart[1] ≤ 22
or GetVersionPart[1] = 22 and GetVersionPart[2] = 0
. That’s very flexible and gives us data in a form that is easy to use.
Now, imagine for a second, that we didn’t need to write the custom function to get the version and Claris had built a function to do that for us. That would be great!
Now, imagine that Claris has built the function, and forgotten to document it.
Get ( DBEngineVersion ) /* returns 220010068 for FileMaker Pro version 22.0.1.68 */