How to detect the operating system

BlitzMax Forums/BlitzMax Beginners Area/How to detect the operating system

cps(Posted 2016) [#1]
Or ' alternate uses for popular functions'. I stumbled across this and can't find a previous thread for it so..
How can you tell PC's and MAC's apart? (I know.. If it works - it's a MAC. If you enjoy programming on it - Its a Mac. If you go all misty eyed when talking about your programing environment - It's a mac.)
However what do you do if you want to use the same source code for both OS's but with minor changes to each IE different font sizes?
The code below though not intended for this purpose seems to work IE it differentiates between MAC OSX(Snow Leopard) and Windows (Vista, XP, W10).

If HostName(HostIp ("", 0))="" then' you are on a MAC (OSX)
' do MAC specific things (set MAC font size)
else' you are on a PC (win)
' do PC specific things (set PC font size)
end if

Hope this is helpful to somebody, have fun Cps (sorry for the duplication I hit the tab key..)


cps(Posted 2016) [#2]
Sorry but a much better way of doing this has been supplied by 'grable' (see duplicate thread).
I strongly recommend ignoring my method and using a variation of this instead.

?MacOS
Print "MAC"
?Win32
Print "WIN"
?

This solution was posted by 'grable' many thanks Cps