Page 1 of 1

How to Get Size Of Variables with arrays

Posted: Sun Dec 28, 2003 6:41 pm
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

Posted: Sun Dec 28, 2003 7:23 pm
by einander
Hi lkd85:
To get the dimension of an array:

Code: Select all

Dim testarr.l(100) 
Debug PeekL(@testarr()-8)
Regards - Einander

Posted: Sun Dec 28, 2003 7:52 pm
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

Posted: Mon Dec 29, 2003 2:31 am
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.

Posted: Mon Dec 29, 2003 3:27 am
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. :)