[PB4.6B4] OSversion()

Just starting out? Need help? Post your questions and find answers here.
buzzqw
Enthusiast
Enthusiast
Posts: 116
Joined: Sat Aug 27, 2005 10:13 pm
Location: Italy
Contact:

[PB4.6B4] OSversion()

Post by buzzqw »

try this code on a Windows machine (tested on win7)

Code: Select all

If OSVersion()<=#PB_OS_Linux_Future
    MessageRequester("OS","Linux")
EndIf
get the same message if executing

Code: Select all

If OSVersion()<=#PB_OS_Windows_Future  
  MessageRequester("OS","Windows")
EndIf
the first command should be true only on a Linux box...

BHH

P.S. i compile the code on windows and linux box
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: [PB4.6B4] OSversion()

Post by ts-soft »

This is a runtime function, you have to use compilerdirectives:

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
If OSVersion()<=#PB_OS_Linux_Future
  MessageRequester("OS","Linux")
EndIf 
CompilerElse
If OSVersion()<=#PB_OS_Windows_Future 
  MessageRequester("OS","Windows")
EndIf 
CompilerEndIf
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: [PB4.6B4] OSversion()

Post by DarkDragon »

buzzqw wrote:the first command should be true only on a Linux box...
How the hell should that work? It would mess up all calculations in the world.

As #PB_OS_Linux_Future isn't equal with #PB_OS_Windows_Future one of them is always smaller than the other one.
bye,
Daniel
buzzqw
Enthusiast
Enthusiast
Posts: 116
Joined: Sat Aug 27, 2005 10:13 pm
Location: Italy
Contact:

Re: [PB4.6B4] OSversion()

Post by buzzqw »

thanks ts-soft!

the help manual abot osversion don't mention this "compilerdirectives"


BHH
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: [PB4.6B4] OSversion()

Post by PMV »

You should only read, what is written in the help.
windows help wrote: #PB_OS_Windows_NT3_51
#PB_OS_Windows_95
#PB_OS_Windows_NT_4
#PB_OS_Windows_98
#PB_OS_Windows_ME
#PB_OS_Windows_2000
#PB_OS_Windows_XP
#PB_OS_Windows_Server_2003
#PB_OS_Windows_Vista
#PB_OS_Windows_Server_2008
#PB_OS_Windows_7
#PB_OS_Windows_Future
No linux, right? So on a windows platform, it will not output linux constants.
In the linux help there will be only #PB_OS_Linux_XXX constants.
OSVersion() is only to get the version of the used OS, not to check against
mac/linux/win. And that is, what the help says. If you want to know, what
OS is used, you need the compiler constant #PB_Compiler_OS. And if you
only want to know, if it is linux or windows, you doesn't need OSVersion()
and your program will maybe work in the future. :wink:

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  MessageRequester("OS","Linux")
CompilerElse
  MessageRequester("OS","Windows")
CompilerEndIf
MFG PMV
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: [PB4.6B4] OSversion()

Post by ts-soft »

@PMV
your example doesn't work on my mac :twisted:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: [PB4.6B4] OSversion()

Post by PMV »

When im running that code on this Mac Book Pro ... it says windows ... and it's right. :mrgreen:
Post Reply