Discovering+the+system+power+status

//by Richard Russell, October 2011//

The code listed below reports the current system power status, including whether the PC is operating from batteries or from the mains, the current battery status and the remaining battery life (if appropriate). code format="bb4w" DIM sps{ACLineStatus&, BatteryFlag&, BatteryLifePercent&, Reserved1&, \ \      BatteryLifeTime%, BatteryFullLifeTime%} SYS "GetSystemPowerStatus", sps{} CASE sps.ACLineStatus& OF       WHEN 0: PRINT "Operating from batteries" WHEN 1: PRINT "Operating on mains" ENDCASE CASE sps.BatteryFlag& OF       WHEN 1: PRINT "Battery charge status is high" WHEN 2: PRINT "Battery charge status is low" WHEN 4: PRINT "Battery charge status is critical" WHEN 8: PRINT "Battery is charging" WHEN 128: PRINT "No battery fitted" ENDCASE IF sps.BatteryLifeTime%<>-1 THEN PRINT "Approximate remaining battery life is "; \ \    sps.BatteryLifeTime% DIV 60 " minutes" ENDIF IF sps.BatteryFullLifeTime%<>-1 THEN PRINT "Approximate battery life when fully charged is "; \ \    sps.BatteryFullLifeTime% DIV 60 " minutes" ENDIF code