Initial Working Script, more to go but this DOES work... thanx to those that assisted...
BTW, it does Compile cleanly without any other than the default Extender, too.
Using 2021D at the moment.
; SCRIPT to find Total & Available Memory on a System
; not the prettiest or best implementation but on my Win10pro System it works just fine.
#DefineFunction AddCommas(passednumstring)
; call as: AddCommas(number_to_format)
; Grab everything to the left of the decimal (if any)
intpart=ItemExtract(1,passednumstring, ".")
;Grab everything to the right of the decimal
fractpart=ItemExtract(2,passednumstring,".")
;Compute how many comma seperated groups we need
groups= ((StrCharCount(intpart)-1) / 3 ) +1
;Initialize an answer variable to a null string
answer=""
;Figure out what each group looks like and add each
;group to the answer variable with a comma.
For y = 1 To groups
If y == 1
ptr=( (StrCharCount(intpart)-1) mod 3) +1
answer=StrSub(intpart,1, ptr )
ptr=ptr +1
Else
answer=StrCat(answer, ",", StrSub(intpart, ptr , 3))
ptr=ptr +3
EndIf
Next
;Now that we have the numbers to the left of the decimal point
;"comma-ized" properly, see if there is any fractional part to
;worry about.
;If there is a fractional part, glue it onto the end of the
;"comma-ized" number along with a decimal point.
If fractpart != ""
answer=StrCat(answer,".",fractpart)
EndIf
;Return the comma-ized answer
Return (answer)
#EndFunction
;---
strComputer = "."
objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" : strComputer : "\root\cimv2")
objRefresher = CreateObject("WbemScripting.Swbemrefresher")
objOperatingSystem = objRefresher.AddEnum(objWMIService, "Win32_OperatingSystem").ObjectSet
FreeMem = 0
TotMem = 0
FreePercent = 0
objRefresher.Refresh
ForEach RefreshItem In objRefresher
ForEach object In RefreshItem.ObjectSet
FreeMem = object.FreePhysicalMemory
TotMem = object.TotalVisibleMemorySize
next
next
FreePercent = (Freemem * 100/TotMem)
Message("Free Memory Snapshot", StrFixCharsL(AddCommas(TotMem), " ",12):" KB Total memory":@lf: StrFixCharsL(AddCommas(FreeMem)," ",12):" KB Free memory":@lf: StrFixCharsL(FreePercent," ",12):"%% Available")
Exit