How to Get Size Of Variables with arrays

Just starting out? Need help? Post your questions and find answers here.
lkd85
New User
New User
Posts: 4
Joined: Sun Dec 28, 2003 6:32 pm

How to Get Size Of Variables with arrays

Post by lkd85 »

Hi, I'm brand new to PureBasic and I was wondering if there's an easier
workaround to finding the size of a variable with an array without manually multiplying the array size. PureBasic doesn't seem to have a UBound or LBound function either.

Ex.

Dim testarr.l(100)

;SizeOf(testarr) doesn't work so I just did 4*100
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

Post by einander »

Hi lkd85:
To get the dimension of an array:

Code: Select all

Dim testarr.l(100) 
Debug PeekL(@testarr()-8)
Regards - Einander
freak
PureBasic Team
PureBasic Team
Posts: 5953
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

To get the total size of an Array in memory, you can also use this
little trick:

viewtopic.php?p=38916#38916

Timo
quidquid Latine dictum sit altum videtur
lkd85
New User
New User
Posts: 4
Joined: Sun Dec 28, 2003 6:32 pm

Post by lkd85 »

Fast replies! To both einander and freak thanks! I also found the same code in the CodeArchive file and I compiled a little array library dll out of the code samples. PureBasic has almost(if not) everything I need for serious 3D gaming(which I plan to do) without the sacrifice of speed.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

PureBasic has almost(if not) everything I need for serious 3D gaming(which I plan to do) without the sacrifice of speed.
Don't forget that Fred has said in a previous post that the native commands for the 3d engine are going to be re-visited and expanded upon for the future! The OGRE engine which is used by PB is no way near used to its fullest yet by PB (sparse command set). Hopefully this will change soon. :)
--Kale

Image
Post Reply