SizeOf( Array() ) ?
-
- Enthusiast
- Posts: 384
- Joined: Sat May 24, 2003 8:02 pm
- Location: Canada
- Contact:
SizeOf( Array() ) ?
Does anybody know how to get the sizeof() an array.... not the upper or lower bounds of the elements but the actually length in bytes of the whole array ... or at least the length in bytes of one array ?
<br>"I deliver Justice, not Mercy"
    - Codemonger, 2004 A.D.
    - Codemonger, 2004 A.D.
Code: Select all
Procedure.l ArrayMemorySize(*Array)
!sub [esp], dword 8
!push dword [esp]
!push dword 0
!push dword [PB_MemoryBase]
!call _HeapSize@12
ProcedureReturn
HeapSize_(0, 0, 0) ; make sure, _HeapSize@12 is defined
EndProcedure
Procedure ArraySize(*Array)
ProcedureReturn PeekL(*Array-8)
EndProcedure
Dim Array.l(50)
Debug ArrayMemorySize(@Array())
Debug ArraySize(@Array())
ArraySize() shows the total number of elements.
Timo
quidquid Latine dictum sit altum videtur
-
- Enthusiast
- Posts: 384
- Joined: Sat May 24, 2003 8:02 pm
- Location: Canada
- Contact:
Freak I have a question for you:freak wrote: Procedure.l ArrayMemorySize(*Array)
!sub [esp], dword 8
!push dword [esp]
!push dword 0
!push dword [PB_MemoryBase]
!call _HeapSize@12
ProcedureReturn
HeapSize_(0, 0, 0) ; make sure, _HeapSize@12 is defined
EndProcedure
HeapSize_(0, 0, 0) ; make sure, _HeapSize@12 is defined
comes after:
ProcedureReturn
and I thought ProcedureReturn is like a break because it exits the Procedure right away.
So:
HeapSize_(0, 0, 0) ; make sure, _HeapSize@12 is defined
will never be executed... or am I wrong

I am to provide the public with beneficial shocks.
Alfred Hitshock
Yes, you are right, and calling HeapSize with a lot of 0's would definatelyFreak I have a question for you:
HeapSize_(0, 0, 0) ; make sure, _HeapSize@12 is defined
comes after:
ProcedureReturn
and I thought ProcedureReturn is like a break because it exits the Procedure right away.
So:
HeapSize_(0, 0, 0) ; make sure, _HeapSize@12 is defined
will never be executed... or am I wrong
fail.
I call the HeapSize directly from asm, ans since it is external, it has to
be defined with
!extrn _HeapSize@12
in order to be used. The problem is, as soon as somebody uses
HeapSize_(), PB will automatically define the symbol, and you get an
'allready defined' error. So, to prevent that, i just insert HeapSize_() at
some point, where it will never be executed, just so that PB defines the
symbol for me.
Dirty little trick, i know, but...

Timo
quidquid Latine dictum sit altum videtur
very handy for the a new UBOUND(Array) Command:
Code: Select all
Dim MYArray.b(4711)
Procedure Ubound(*Array)
ProcedureReturn PeekL(*Array-8)
endprocedure
Debug Str(UBound(@MyArray(0)))
SPAMINATOR NR.1
thanks @Rings, but this Source have many errors. It does not rearly help.
Here the german link.
http://robsite.de/php/pureboard/viewtopic.php?t=1318
Can any help me please to corecting this source?
Sorry, my english from german post,
Falko
Here the german link.
http://robsite.de/php/pureboard/viewtopic.php?t=1318
Can any help me please to corecting this source?
Sorry, my english from german post,
Falko
------GERAMAN---------------Falko wrote:thanks @Rings, but this Source have many errors. It does not rearly help.
Here the german link.
http://robsite.de/php/pureboard/viewtopic.php?t=1318
Can any help me please to corecting this source?
Sorry, my english from german post,
Falko
Hi Falko,
LBound in PureBasic ist IMMER 0 !!!
In anderen Sprachen ist es möglich ein Array zu definieren, das von 50 bis 100 geht, wobei LBOUND in diesem Fall 50 ist. Würde man einen Index außerhalb dem Bereich [50-100] aufrufen würde es eine Fehlermeldung geben.
------ENGLISH---------------
LBound in PureBasic is ALWAYS 0 !!!
In otzer programming languages it is possible to define arrays (i.e.) from 50 to 100. In this case LBOUND would return 50. If you would try to get an index outside the range [50-100] an error would occur.
cu, helpy