tedmonson
(Lurker)
2003-07-12 12:00 AM
MemorySize Function

The MemorySize() function currently returns a maximum of 2047 MB, would be nice to return the correct value when more than this amount.

Kdyer
(KiX Supporter)
2003-07-12 12:03 AM
Re: MemorySize Function

What about the WMIQUERY() UDF? Granted, it not "native" KiXtart, but should work for you.

Kent


LonkeroAdministrator
(KiX Master Guru)
2003-07-12 12:07 AM
Re: MemorySize Function

I vote for this too.
as integer is getting small, we might need to have double as default vartype for numbers.


Radimus
(KiX Supporter)
2003-07-12 04:48 AM
Re: MemorySize Function

code:
	for each $dimm in WMIQuery("Capacity","Win32_PhysicalMemory")
$mem[$a]=val($dimm) / 1048576
$memory=val($memory)+val($mem[$a])
$a=val($a)+1
next
$dimm1=$mem[0] $dimm2=$mem[1] $dimm3=$mem[2]



[ 12. July 2003, 04:48: Message edited by: Radimus ]


NTDOCAdministrator
(KiX Master)
2003-07-12 09:52 AM
Re: MemorySize Function

Rad,

Your code produces an error on my system.

ERROR : invalid method/function call: missing ')'!
Line : 4

Line 4 is this one:
$memory=val($memory)+val($mem[$a])

http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=12;t=000117


break on
for each $dimm in WMIQuery("Capacity","Win32_PhysicalMemory")
$mem[$a]=val($dimm) / 1048576
$memory=val($memory)+val($mem[$a])
$a=val($a)+1
next
$dimm1=$mem[0] $dimm2=$mem[1] $dimm3=$mem[2]

FUNCTION WMIQuery($sWhat, $sFrom, Optional $sComputer, Optional $sWhere, Optional $x)
Dim $sQuery, $objEnum, $sValue, $sItem, $lUbound
Dim $aTMP[0]

$sQuery = "Select " + $sWhat + " From "+ $sFrom
If Not $sComputer $sComputer=@WKSTA EndIf
If $sWhere AND $x $sQuery = $sQuery + " Where " + $sWhere + " = '"+$x+"'" EndIf

$SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//"+$sComputer)
If @ERROR Exit VAL("&"+Right(DecToHex(@ERROR),4)) Return EndIf

$objEnum = $SystemSet.ExecQuery($sQuery)
If @ERROR Exit VAL("&"+Right(DecToHex(@ERROR),4)) Return EndIf

For Each $objInstance in $objEnum
If $objInstance
$=Execute("$$sValue = $$objInstance.$sWhat")
Select
Case VarType($sValue) & 8192
For Each $sItem in $sValue
$lUbound = Ubound($aTMP)
If $aTMP[$lUbound] >' '
$lUbound = $lUbound +1
Redim Preserve $aTMP[$lUbound]
EndIf
$aTMP[$lUbound] = Trim($sItem)
Next
Case 1
$lUbound = Ubound($aTMP)
If $aTMP[$lUbound] >' '
$lUbound = $lUbound +1
Redim Preserve $aTMP[$lUbound]
EndIf
$aTMP[$lUbound] = Trim($sValue)
EndSelect
EndIf
Next
$WMIQuery = $aTMP
Exit VAL("&"+Right(DecToHex(@ERROR),4))
ENDFUNCTION


[ 12. July 2003, 09:53: Message edited by: NTDOC ]


Radimus
(KiX Supporter)
2003-07-12 01:12 PM
Re: MemorySize Function

sorry...

code:
 
break on

$a=0
$mem=WMIQuery("Capacity","Win32_PhysicalMemory")
for each $dimm in $mem
$mem[$a]=val($dimm) / 1048576
$memory=$memory + $mem[$a]
$a=$a + 1
next
? $memory
for each $stick in $mem
? $stick
next



NTDOCAdministrator
(KiX Master)
2003-07-12 09:53 PM
Re: MemorySize Function

Thanks Rad,

Here is a minor modification for a better look on the console.






break on
$a=0
$Index=0
$mem=WMIQuery("Capacity","Win32_PhysicalMemory")
for each $dimm in $mem
$mem[$a]=val($dimm) / 1048576
$memory=$memory + $mem[$a]
$a=$a + 1
next
for each $stick in $mem
? 'Memory Slot '+$Index +': '+$stick
$Index=$Index+1
next
? 'Total Memory : '+$memory




[ 12. July 2003, 21:55: Message edited by: NTDOC ]


LonkeroAdministrator
(KiX Master Guru)
2003-07-13 03:30 AM
Re: MemorySize Function

boys, sure we can do all the tasks with com and use kix only for createobject stuff.

but that is not funny.
we can use wsh for that just fine.

I really beg for improvement to this.


Sealeopard
(KiX Master)
2003-07-13 08:49 PM
Re: MemorySize Function

I have to agree with Jooel on this one. It can definitley be classified as a bug due to the fact that an INT is being returned instead of a DBL. Thus, the MEMORYSIZE() function needs to be updated to either return a DBL or integer values will be declared a LONG INT by default instead of an INT.

LonkeroAdministrator
(KiX Master Guru)
2003-07-13 10:01 PM
Re: MemorySize Function

hmm...
we had that int versus long int discussion before.
there actually is no more int in kix.
no matter how you try, you can't make integer values.

anyway, not sure can I call it a bug, but it damn sure is a limitation.
it's like trying to run your domain with win95 as clients.
the upper boundary limit has been reached and that makes the need to enchange kixtart so it will not be outdated.


LonkeroAdministrator
(KiX Master Guru)
2003-09-22 10:51 PM
Re: MemorySize Function

bumb.
ruud?


Arend_
(MM club member)
2007-07-05 09:25 AM
Re: MemorySize Function

Not sure whether 2048 is the limit or MemorySize() only reading BANK0.

LonkeroAdministrator
(KiX Master Guru)
2007-07-05 12:17 PM
Re: MemorySize Function

2GB is the limit.

LonkeroAdministrator
(KiX Master Guru)
2007-07-12 08:21 AM
Re: MemorySize Function

ok, here is link to the real thread:
http://www.kixtart.org/forums/ubbthreads.php?ubb=showflat&Board=3&Number=154602

and you can see there ruud's comments.
it's a bug in the api.

works fine in vista.


NTDOCAdministrator
(KiX Master)
2007-07-12 09:58 AM
Re: MemorySize Function

There is a UDF from Glenn Barnas as well that does not have this 2GB limitation. It is overall memory not slots though.

Arend_
(MM club member)
2007-07-12 10:32 AM
Re: MemorySize Function

WMI doesn't have this problem either.
 Code:
$memcol = GetObject("winmgmts:\\.\root\cimv2").InstancesOf("Win32_MemoryArray")
For Each $mem in $memcol
  ? $mem.EndingAddress
Next


Returns the total amount of memory


LonkeroAdministrator
(KiX Master Guru)
2007-07-12 10:39 AM
Re: MemorySize Function

ja... don't think wmi uses the api though.
or it would fail too \:\)