Getting the Version number

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 */

13 Likes

haha. The Master of Suspense! :slight_smile:

Very cool finding! How did you find out about it?

Thanks

3 Likes

Our lead dev was asking us how to trap for the version number. We all came back with suggestions like the ones above, but he kept saying, no, no, no, I want the function that just returns the number!

He had got it from a conversation with one of the Claris devs, but had forgotten it. Fortunately we located it by searching our DDR repo.

2 Likes

If all you need is the major version, use Int ( Get (ApplicationVersion))

2 Likes

that’s if you’re using the period as a decimal separator. Doesn’t work for every file.

1 Like

This is super duper cool, thanks. Makes you wonder what else is lurking under the hood.

Quick note about this:

I think the separator in the file locale elements could differ from what is used in Get(ApplicationVersion), so it’s a good idea to parse out the separator from Get(ApplicationVersion)directly. E.g. one way:

Let ([
	~av = Get ( ApplicationVersion ) ;
	~version = Middle ( ~av ; Position ( ~av ; " " ; 1 ; 1 ) + 1 ; length ( ~av ) ) ;
	~sep = left ( substitute ( ~version ; [0;""] ; [1;""] ; [2;""] ; [3;""] ; [4;""] ; [5;""] ; [6;""] ; [7;""] ; [8;""] ; [9;""] ) ; 1 ) ;
	~av_list = substitute ( ~version ; ~sep ; ¶ ) ;
	~maj = GetValue ( ~av_list ; 1 ) ;
	~min = GetValue ( ~av_list ; 2 ) ;
	~patch = GetValue ( ~av_list ; 3 )
];
	// use ~maj/~min/~patch
)

Maybe someone here can confirm. @FabriceN ?

1 Like

I confirm that Get (ApplicationVersion) always uses periods as separators regardless of locale.

3 Likes

Don’t tell Claris, someone may think it’s a bug and ask to correct that :smiley: .

2 Likes

There are a number of reasons to use Get ( ApplicationVersion ), including:

[1] Checking that the client software is running a high enough version to use a feature

[2] Check that the version is OK or should upgrade by providing lists of:

$applicationVersion_is_OK_list

$applicationVersion_should_upgrade_list

// blog post for another day

@bdbd and others in the community have reported that the numeric portion of the text string returned by Get ( ApplicationVersion ) is dot delimited in {most likely} all languages/locals.

On the other hand, different languages/locals use different characters to delimit the integer part and the decimal places of a number.

Both Int ( "22.0.1" ) and GetAsNumber ( "22.0.1" ) seem to make use of the first delimiter and remove the later one(s), returning 22 and 22.01 respectively.

This works well as a method of returning the major portion of the ApplicationVersion only if the languages/locals uses a dot charter to delimit the integer part and the decimal places of a number

It is also important to note that checking for only the major release part is not as robust as parsing major.minor.patch out and checking for major, minor, and patch. For example you might be checking for features released in 19.6.1

Happy FileMaker’ing to all our friends working in...

// might have errors here ↴

English // 123.45

French // 123,45

German // 123,45

Italian // 123,45

Dutch // 123,45

Spanish // 123,45

Swedish // 123,45

Japanese // QQQ

Brazilian-Portuguese // 123,45

Korean and Simplified // QQQ

…languages!

1 Like

Thanks for confirming @bdbd :slight_smile:

Get ( ApplicationVersion ) returns a constant string, with dots.
You can get the decimal separator of a file by either looking a the locale (Get ( FileLocaleElements )), or simply by parsing a decimal number: Middle ( 3/2 ; 2 ; 1 )

1 Like