OSVersion() for macOS Ventura

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Quin
Enthusiast
Enthusiast
Posts: 258
Joined: Thu Mar 31, 2022 7:03 pm
Location: United States
Contact:

OSVersion() for macOS Ventura

Post by Quin »

Hi,
macOS 13 (Ventura) has recently been released. OSVersion() doesn't yet support it, though, with the latest it supports being #PB_OS_MacOSX_12. Can Ventura support possibly be added?
Thanks!
PB v5.40/6.10, Windows 10 64-bit.
16-core AMD Ryzen 9 5950X, 128 GB DDR5.
User avatar
mk-soft
Always Here
Always Here
Posts: 5313
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: OSVersion() for macOS Ventura

Post by mk-soft »

Workaround ...

Code: Select all

;-TOP my mk-soft, Update 16.01.2024

CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
  CompilerIf Not Defined(PB_OS_MacOSX_13, #PB_Constant)
    #PB_OS_MacOSX_13 = 13000
    #PB_OS_MacOSX_14 = 14000
    
    Structure udtOSVersion
      majorVersion.i
      minorVersion.i
      patchVersion.i
    EndStructure
    
    Procedure MacOSVersion()
      Static NSVersion.udtOSVersion
      Protected Version, NSProcessInfo
      
      If Not NSVersion\majorVersion
        NSProcessInfo = CocoaMessage(0, 0, "NSProcessInfo processInfo")
        CocoaMessage(NSVersion, NSProcessInfo, "operatingSystemVersion")
      EndIf
      Version = NSVersion\majorVersion * 1000 + NSVersion\minorVersion * 10
      ProcedureReturn Version
    EndProcedure
    
    Macro OSVersion()
      MacOSVersion()
    EndMacro
  CompilerEndIf
CompilerEndIf

Debug OSVersion()

If OSVersion() >= #PB_OS_MacOSX_14
  MessageRequester("Info", "OS Version Sonoma")
ElseIf OSVersion() >= #PB_OS_MacOSX_13
  MessageRequester("Info", "OS Version Ventura")
EndIf
Last edited by mk-soft on Tue Jan 16, 2024 6:40 pm, edited 1 time in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Quin
Enthusiast
Enthusiast
Posts: 258
Joined: Thu Mar 31, 2022 7:03 pm
Location: United States
Contact:

Re: OSVersion() for macOS Ventura

Post by Quin »

Amazing, thanks a lot for this! :) Would still love to see this make it into the stdlib, though
PB v5.40/6.10, Windows 10 64-bit.
16-core AMD Ryzen 9 5950X, 128 GB DDR5.
Quin
Enthusiast
Enthusiast
Posts: 258
Joined: Thu Mar 31, 2022 7:03 pm
Location: United States
Contact:

Re: OSVersion() for macOS Ventura

Post by Quin »

With macOS Sonoma rapidly approaching public release, I'm going ahead and bumping this. Both Ventura and Sonoma constants would be great! :)
PB v5.40/6.10, Windows 10 64-bit.
16-core AMD Ryzen 9 5950X, 128 GB DDR5.
Quin
Enthusiast
Enthusiast
Posts: 258
Joined: Thu Mar 31, 2022 7:03 pm
Location: United States
Contact:

Re: OSVersion() for macOS Ventura

Post by Quin »

Bumping once again. I now have an application that collects information about the OS a user is running, and it's incredibly unhelpful nowadays to just get Future for 13 and 14. This also seems like the sort of thing that 6.10 is after.
PB v5.40/6.10, Windows 10 64-bit.
16-core AMD Ryzen 9 5950X, 128 GB DDR5.
mrbungle
Enthusiast
Enthusiast
Posts: 111
Joined: Wed Dec 30, 2020 3:18 am

Re: OSVersion() for macOS Ventura

Post by mrbungle »

Reference: https://www.purebasic.fr/english/viewto ... on#p591872
Courtesy of mk-soft

Code: Select all

;-TOP my mk-soft, Update 28.11.2022

CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
  CompilerIf Not Defined(PB_OS_MacOSX_13, #PB_Constant)
    #PB_OS_MacOSX_13 = 13000
  
    Structure udtOSVersion
      majorVersion.i
      minorVersion.i
      patchVersion.i
    EndStructure
    
    Procedure MacOSVersion()
      Static NSVersion.udtOSVersion
      Protected Version, NSProcessInfo
      
      If Not NSVersion\majorVersion
        NSProcessInfo = CocoaMessage(0, 0, "NSProcessInfo processInfo")
        CocoaMessage(NSVersion, NSProcessInfo, "operatingSystemVersion")
      EndIf
      Version = NSVersion\majorVersion * 1000 + NSVersion\minorVersion * 10
      ProcedureReturn Version
    EndProcedure
    
    Macro OSVersion()
      MacOSVersion()
    EndMacro
  CompilerEndIf
CompilerEndIf

Debug OSVersion()

If OSVersion() >= #PB_OS_MacOSX_13
  MessageRequester("Info", "OS Version Ventura")
EndIf

Quin
Enthusiast
Enthusiast
Posts: 258
Joined: Thu Mar 31, 2022 7:03 pm
Location: United States
Contact:

Re: OSVersion() for macOS Ventura

Post by Quin »

What's the constant for Sonoma? I tried 14000 but that didn't seem to work.
mrbungle wrote: Mon Jan 15, 2024 10:32 pm Reference: https://www.purebasic.fr/english/viewto ... on#p591872
Courtesy of mk-soft

Code: Select all

;-TOP my mk-soft, Update 28.11.2022

CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
  CompilerIf Not Defined(PB_OS_MacOSX_13, #PB_Constant)
    #PB_OS_MacOSX_13 = 13000
  
    Structure udtOSVersion
      majorVersion.i
      minorVersion.i
      patchVersion.i
    EndStructure
    
    Procedure MacOSVersion()
      Static NSVersion.udtOSVersion
      Protected Version, NSProcessInfo
      
      If Not NSVersion\majorVersion
        NSProcessInfo = CocoaMessage(0, 0, "NSProcessInfo processInfo")
        CocoaMessage(NSVersion, NSProcessInfo, "operatingSystemVersion")
      EndIf
      Version = NSVersion\majorVersion * 1000 + NSVersion\minorVersion * 10
      ProcedureReturn Version
    EndProcedure
    
    Macro OSVersion()
      MacOSVersion()
    EndMacro
  CompilerEndIf
CompilerEndIf

Debug OSVersion()

If OSVersion() >= #PB_OS_MacOSX_13
  MessageRequester("Info", "OS Version Ventura")
EndIf

PB v5.40/6.10, Windows 10 64-bit.
16-core AMD Ryzen 9 5950X, 128 GB DDR5.
User avatar
mk-soft
Always Here
Always Here
Posts: 5313
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: OSVersion() for macOS Ventura

Post by mk-soft »

My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply