Definition: | integer i = platform() |
Description: | platform() is a function built-in to the interpreter. It indicates the platform that the program is being executed on: WINDOWS or LINUX . |
Comments: | When
p.exe or pw.exe
is running the platform is Windows. When
phix
is running the platform is LINUX
Phix implicitly defines (via psym.e/syminit) the following constants: global constant --DOS32 = 1, WINDOWS = 2, LINUX = 3 DOS programming has never been supported by phix, not that I have any objections to someone else adding it. The deprecated constant WIN32 is the same as WINDOWS; it does not mean 32-bit. (See machine_bits() and machine_word()). Use platform() when you want to execute different code depending on which platform the program is running on. Additional platforms may be added as phix is ported to new machines and operating environments. The legacy DOS32 platform is not supported. The call to platform() costs nothing. It is optimized at compile-time into the appropriate integer value: 2 or 3. Further, no code whatsoever will be emitted for the comparison, else, and one of the two branches in the following example. |
Example: |
if platform()=WINDOWS then puts(1,"hello Windows") elsif platform()=LINUX then puts(1,"hello Linux") else puts(1,"has someone added another platform I don't know about?") end if |
See Also: | machine_bits, machine_word, format directive |