KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Ways to check Operating System Type Running 4D
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: November 8, 2018
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

With the new features introduced in v17, there are a large number of ways to check the operating system type that is currently being used which can be helpful when dealing with cross platform targetted databases that have unique actions to perform based on the differences in the OS.

Below are some of the more simple ways to check:

1) New dedicated commands introduced in v17:
Two new dedicated commands have been made available, Is macOS and Is Windows will return a true if the operating system is correct or a false otherwise.

Example:

If(Is macOS)
//Is a macOS
Else
//Is not a macOS
End if


If(Is Windows)
//Is a Windows
Else
//Is not a Windows
End if


2) Checking the folder separator avaliable in older and newer versions of 4D:
This was a simple trick used to check the operating system since, macOS used colons and windows used backslashes.

Example:
If(Folder separator=":")
//Is a macOS
Else
//Is not a macOS
End if


If(Folder separator="\\")
//Is a Windows
Else
//Is not a Windows
End if


3) PLATFORM PROPERTIES command in v16 and older and is now considered deprecated by the dedicated commands mentioned above.
This command would return the operating system used in the first parameter as a longint value which could be checked by the comparing to the constants Mac OS (2) and Windows (3).

Example:
C_LONGINT($os_l)
PLATFORM PROPERTIES($os_l)

If ($os_l=Mac OS)
  //Is a macOS
Else
  //Is not a macOS
End if

If ($os_l=Windows)
//Is a Windows
Else
//Is not a Windows
End if