PlatformInfoLib — Platform Information

Detect and query operating system information. Useful for cross-platform applets that adapt behavior based on the host system. 8 unique functions + 2 overloads = 10 registered signatures.

CategoryCountDescription
Platform ID3os_platform$, os_name$, os_architecture$
Version Info3os_major, os_minor, os_build
Version Check2os_check (2-param and 3-param overloads)
Service Pack2os_spmajor, os_spminor
Supported PlatformIdentificationArchitecture
Windows 10/11Windows 10 / Windows 11IntelX86, IntelX64
macOSmacOS Sonoma, etc.IntelX64, ARM64 (Apple Silicon)
LinuxLinuxIntelX64, ARM64
AndroidAndroidARM32, ARM64
iOSiOSARM64

Platform Identification

FunctionSignatureDescription
os_platform$()os_platform$@Full platform description (name + version + architecture)
os_name$()os_name$@OS name only (e.g. "Windows 11", "macOS Sonoma", "Android")
os_architecture$()os_architecture$@CPU architecture string
Platformos_platform$() Example
Windows 11Windows 11 (Version 23H2, Build 22631, 64-bit)
Windows 10Windows 10 (Version 21H2, Build 19044, 64-bit)
macOSmacOS 14.0 (Build 23A344)
LinuxLinux (Ubuntu 22.04)
AndroidAndroid 13.0
iOSiOS 17.0
Architecture ValueDescription
IntelX8632-bit Intel/AMD
IntelX6464-bit Intel/AMD
ARM3232-bit ARM
ARM6464-bit ARM (Apple Silicon, modern mobile, etc.)
╯ plan9basic
println "Platform: "; os_platform$()
println "OS Name:  "; os_name$()
println "Arch:     "; os_architecture$()

' Platform-specific branching
name$ = os_name$()
if instr(name$, "Windows") >= 0 then
    println "Windows-specific code"
else if instr(name$, "macOS") >= 0 then
    println "macOS-specific code"
else if instr(name$, "Android") >= 0 then
    println "Android-specific code"
endif

Version Information

FunctionSignatureDescription
os_major()os_major@Major version number
os_minor()os_minor@Minor version number
os_build()os_build@Build number
PlatformMajorMinorBuild Notes
Windows 11100Build ≥ 22000 indicates Win 11
Windows 10100Build < 22000
macOS Sonoma14xDirectly maps to macOS version
macOS Ventura13x
Android 13130Corresponds to Android version
iOS 1717xCorresponds to iOS version
╯ plan9basic
println "Version: "; os_major(); "."; os_minor()
println "Build:   "; os_build()

' Windows 11 detection (both Win 10 & 11 report major=10)
if os_major() = 10 then
    if os_build() >= 22000 then
        println "Windows 11"
    else
        println "Windows 10"
    endif
endif
⚠ Warning: On Windows, both Windows 10 and 11 report os_major() = 10. Use os_build() ≥ 22000 to detect Windows 11.

Version Checking

FunctionSignatureDescription
os_check(major, minor)os_check@nnOS version ≥ specified? (1/0)
os_check(major, minor, sp)os_check@nnnVersion + service pack check (1/0)
╯ plan9basic
' Require Windows 10+
if os_check(10, 0) = 1 then
    println "Windows 10 or later"
endif

' Require macOS 11 (Big Sur)+
if os_check(11, 0) = 1 then
    println "macOS 11 or later"
endif

' Require Android 10+
if os_check(10, 0) = 1 then
    println "Android 10 or later"
endif

' Legacy: Windows 7 SP1 check
if os_check(6, 1, 1) = 1 then
    println "Windows 7 SP1 or later"
endif
ⓘ Note: The 3-parameter overload with service pack is primarily useful for legacy Windows (7, 8). Modern systems (Win 10+, macOS, Linux, mobile) return 0 for service pack.

Service Pack Information

FunctionSignatureDescription
os_spmajor()os_spmajor@Service pack major version (0 if not applicable)
os_spminor()os_spminor@Service pack minor version (usually 0)
╯ plan9basic
sp = os_spmajor()
if sp > 0 then
    println "Service Pack "; sp; "."; os_spminor()
else
    println "No service pack (or not applicable)"
endif
ⓘ Note: Service packs are a Windows-specific concept. On modern Windows (10+), macOS, Linux, Android, and iOS these functions return 0.

Complete Examples

System Information Display

╯ sysinfo.bas
println "=== System Information ==="
println ""
println "Platform:     "; os_platform$()
println "OS Name:      "; os_name$()
println "Architecture: "; os_architecture$()
println ""
println "Version: "; os_major(); "."; os_minor()
println "Build:   "; os_build()
println ""
if os_spmajor() > 0 then
    println "Service Pack: "; os_spmajor(); "."; os_spminor()
else
    println "Service Pack: N/A"
endif

Platform-Specific Code

╯ platform_detect.bas
println "=== Platform Detection ==="

name$ = os_name$()

if instr(name$, "Windows") >= 0 then
    println "Running on Windows"
    if os_build() >= 22000 then
        println "  Windows 11"
    else if os_major() >= 10 then
        println "  Windows 10"
    else
        println "  Older Windows"
    endif
else if instr(name$, "macOS") >= 0 then
    println "Running on macOS "; os_major(); "."; os_minor()
else if instr(name$, "Linux") >= 0 then
    println "Running on Linux"
else if instr(name$, "Android") >= 0 then
    println "Running on Android "; os_major()
else if instr(name$, "iOS") >= 0 then
    println "Running on iOS "; os_major(); "."; os_minor()
else
    println "Unknown: "; name$
endif

Minimum Version Requirements

╯ requirements.bas
println "=== Requirements Check ==="

allOk = 1
name$ = os_name$()

' Architecture
arch$ = os_architecture$()
println "Architecture: "; arch$
if arch$ = "IntelX86" then
    println "  WARNING: 32-bit - features may be limited"
else
    println "  OK: 64-bit system"
endif

' Platform version checks
if instr(name$, "Windows") >= 0 then
    if os_check(10, 0) = 1 then
        println "Windows: OK (10+)"
    else
        println "Windows: FAIL (requires 10+)"
        allOk = 0
    endif
else if instr(name$, "macOS") >= 0 then
    if os_check(11, 0) = 1 then
        println "macOS: OK (11+)"
    else
        println "macOS: FAIL (requires 11+)"
        allOk = 0
    endif
else if instr(name$, "Android") >= 0 then
    if os_check(10, 0) = 1 then
        println "Android: OK (10+)"
    else
        println "Android: FAIL (requires 10+)"
        allOk = 0
    endif
else if instr(name$, "iOS") >= 0 then
    if os_check(14, 0) = 1 then
        println "iOS: OK (14+)"
    else
        println "iOS: FAIL (requires 14+)"
        allOk = 0
    endif
endif

println ""
if allOk = 1 then
    println "All requirements met!"
else
    println "Some requirements not met."
endif

System Report Generator

╯ report.bas
println "=== System Report ==="

report$ = "SYSTEM REPORT" + chr$(10)
report$ = report$ + "=============" + chr$(10) + chr$(10)
report$ = report$ + "Platform: " + os_platform$() + chr$(10)
report$ = report$ + "OS Name: " + os_name$() + chr$(10)
report$ = report$ + "Architecture: " + os_architecture$() + chr$(10)
report$ = report$ + "Version: " + stri$(os_major(), 0) + "." + stri$(os_minor(), 0) + chr$(10)
report$ = report$ + "Build: " + stri$(os_build(), 0) + chr$(10)

if os_spmajor() > 0 then
    report$ = report$ + "SP: " + stri$(os_spmajor(), 0) + "." + stri$(os_spminor(), 0) + chr$(10)
endif

println report$

Platform-Specific Notes

PlatformNotes
Windowsos_major() returns 10 for both Win 10 and 11. Use os_build() ≥ 22000 for Win 11. Service packs meaningful only for Win 7/8.
macOSos_major() maps directly to version (14=Sonoma, 13=Ventura). os_architecture$() returns ARM64 on Apple Silicon, IntelX64 on Intel Macs. SP returns 0.
LinuxVersion info depends on distribution and kernel. Architecture is accurate. SP returns 0.
Androidos_major() corresponds to Android version. Architecture typically ARM64 or ARM32. SP returns 0.
iOSos_major() maps directly to iOS version. Architecture is ARM64 on modern devices. SP returns 0.

Quick Reference

FunctionSignatureDescription
os_platform$()os_platform$@Full platform description
os_name$()os_name$@OS name only
os_architecture$()os_architecture$@CPU architecture (IntelX86/X64, ARM32/64)
os_major()os_major@Major version number
os_minor()os_minor@Minor version number
os_build()os_build@Build number
os_check(major, minor)os_check@nnVersion ≥ specified? (1/0)
os_check(major, minor, sp)os_check@nnnVersion + SP check (1/0)
os_spmajor()os_spmajor@Service pack major (0 if N/A)
os_spminor()os_spminor@Service pack minor (0 if N/A)

8 unique functions, 10 registered signatures across 4 categories.