Tech Tip: Updating Platform Checking Code
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: June 28, 2021
There are newer and simpler 4D commands to check the platform type using one of two commands, Is macOS and Is Windows. Prior to the release of these commands, this inforamtion would have to be extracted from the system info. These were multiple lines of code and as such stuck into a global variable for reuse.
To create preemptive code, global variables cannot be used in the method, as such it is a good idea to replace platform checks using the mentioned commands.
For example, instead of the following code:
If(<>platfom_TextVar = "Windows") //.... End if |
It can be replaced with the following
If(Is Windows) //... End if |
This can reduce the startup code needed to find the platform and will make methods using this more preemptive ready.