Thanks Al... fixed the post.

Glenn's original code did this

Code:
; Check for invalid read and Return 

If Len($HexDmp) = 0 Or @ERROR
$Memory = 0
$Error = IIf(@ERROR, @ERROR, 87)
Exit $Error
EndIf



After further testing it does appear the original method Glenn used does seem to work.


Glenn is using for 0 length
87 The parameter is incorrect.

Maybe for a zero length use
24 The program issued a command but the command length is incorrect
Or
13 The data is invalid

Which number would everyone rather use?

I'm okay with putting back Glenn's original code for that too.

Overall though I think all of you are missing the bigger picture, yes I did ask about the error codes and I guess those are the easy target to pick out, but really looking for someone to maybe be able to provide a better coding solution overall or agree that at least for now no one can seem to find a better method so the error code changes are the only obvious things that can use some modifications.


Dim $Mem

$Mem=Memory()
If @ERROR
? 'Error: ' + @ERROR
Else
? 'Memory: ' + $Mem
EndIf
Color 'r/w'
? 'Press any key to continue...' ?
Get $Pause




Function Memory(Optional $sComputer)

Dim $MemKey, $HexDmp, $Pointer, $Counter, $Start, $Hex, $HVal, $Hex2Dec
$MemKey = 'HKLM\Hardware\ResourceMap\System Resources\Physical Memory'
$MemKey = IIf((Not $sComputer), $MemKey,('\\'+Join(Split($sComputer,'\'),'',3)+'\'+$MemKey))
$HexDmp = ReadValue($MemKey, '.Translated')
If Len($HexDmp) = 0 Or @ERROR
$Memory = 0
$Error = IIf(@ERROR, @ERROR, 87)
Exit $Error
EndIf
Dim $HVals[((Len($HexDmp) / 32) - 2)]
$Pointer = 0
For $Start = 65 To Len($HexDmp) Step 32
$Hex = ''
For $Counter = 6 To 0 Step -2
$Hex = $Hex + SubStr($HexDmp, $Start + $Counter, 2)
Next
$HVals[$Pointer] = $Hex
$Pointer = $Pointer + 1
Next
For Each $HVal In $HVals
$Hex2Dec = 0.0
While $HVal
$Hex2Dec = 16.0 * $Hex2Dec + Execute('Exit &' + Left($HVal ,1))
$HVal = SubStr($HVal ,2)
Loop
$Memory = $Memory + CDbl($Hex2Dec) / 1024
Next
$Memory = Int(($Memory + 648) / 1024)
If ($Memory Mod 2)=1
$Memory = $Memory+1
EndIf
EndFunction



Edited by NTDOC (2005-02-24 09:05 AM)