Page 1 of 1 1
Topic Options
#81727 - 2003-07-12 12:00 AM MemorySize Function
tedmonson Offline
Lurker

Registered: 2003-07-11
Posts: 2
The MemorySize() function currently returns a maximum of 2047 MB, would be nice to return the correct value when more than this amount.
Top
#81728 - 2003-07-12 12:03 AM Re: MemorySize Function
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
What about the WMIQUERY() UDF? Granted, it not "native" KiXtart, but should work for you.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#81729 - 2003-07-12 12:07 AM Re: MemorySize Function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
I vote for this too.
as integer is getting small, we might need to have double as default vartype for numbers.
_________________________
!

download KiXnet

Top
#81730 - 2003-07-12 04:48 AM Re: MemorySize Function
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
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 ]
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#81731 - 2003-07-12 09:52 AM Re: MemorySize Function
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
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 ]

Top
#81732 - 2003-07-12 01:12 PM Re: MemorySize Function
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
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

_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#81733 - 2003-07-12 09:53 PM Re: MemorySize Function
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
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 ]

Top
#81734 - 2003-07-13 03:30 AM Re: MemorySize Function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#81735 - 2003-07-13 08:49 PM Re: MemorySize Function
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
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.
_________________________
There are two types of vessels, submarines and targets.

Top
#81736 - 2003-07-13 10:01 PM Re: MemorySize Function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#81737 - 2003-09-22 10:51 PM Re: MemorySize Function
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
bumb.
ruud?
_________________________
!

download KiXnet

Top
#177585 - 2007-07-05 09:25 AM Re: MemorySize Function [Re: Lonkero]
Arend_ Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Not sure whether 2048 is the limit or MemorySize() only reading BANK0.
Top
#177602 - 2007-07-05 12:17 PM Re: MemorySize Function [Re: Arend_]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
2GB is the limit.
_________________________
!

download KiXnet

Top
#177844 - 2007-07-12 08:21 AM Re: MemorySize Function [Re: Lonkero]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#177850 - 2007-07-12 09:58 AM Re: MemorySize Function [Re: Lonkero]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
There is a UDF from Glenn Barnas as well that does not have this 2GB limitation. It is overall memory not slots though.
Top
#177853 - 2007-07-12 10:32 AM Re: MemorySize Function [Re: NTDOC]
Arend_ Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
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

Top
#177854 - 2007-07-12 10:39 AM Re: MemorySize Function [Re: Arend_]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ja... don't think wmi uses the api though.
or it would fail too \:\)
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.069 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org