If you don't know in advance, does PureBasic have a method of obtaining the number and range of items in an array? The tools I am used to (VB6, VBScript etc) are LBound and UBound, but PureBasic doesn't seem to have these.
I understand that PureBasic can use linked lists and collections instead of simple one dimensional arrays, so this is probably just me trying to get a job done the wrong way.
Any help (or redirection) would be great.
Size Of Arrays
-
- New User
- Posts: 2
- Joined: Fri Aug 08, 2008 12:56 pm
- Location: United Kingdom
lbound is always zero for PB arrays.
Rumour has it that a forthcoming version of PB will have a cross-platform function for retrieving ubounds of individual array dimensions. In the meantime you can use PeekL(arrayName()-8 ) to get the total number of elements.
Rumour has it that a forthcoming version of PB will have a cross-platform function for retrieving ubounds of individual array dimensions. In the meantime you can use PeekL(arrayName()-8 ) to get the total number of elements.
I may look like a mule, but I'm not a complete ass.
for now either in a macro or however you like it:
Getting the Size of an Array():
Cheers,
Thalius
Getting the Size of an Array():
Code: Select all
PeekL(@Array() - 8)
Thalius
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone!
"
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone!

-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Size Of Arrays
What are "collections"? Am I missing something?PureNewbie wrote:I understand that PureBasic can use linked lists and collections instead of simple one dimensional arrays,
Regards, Little John
-
- New User
- Posts: 2
- Joined: Fri Aug 08, 2008 12:56 pm
- Location: United Kingdom
Size Of Arrays
Many thanks for the replies, I will give your suggestions a go.
My apologies to Little John - for "collections" read "structures" (too many languages going round and round .......).
My apologies to Little John - for "collections" read "structures" (too many languages going round and round .......).
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Size Of Arrays
Ah, I see. No problem.PureNewbie wrote:My apologies to Little John - for "collections" read "structures"
Regards, Little John
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
@PureNewbie
a Structure is nothing in opposide to an Array.
you can put structured elements into an array as well as into a List.
the main difference is between Arrays and LLists:
an Array has fixed Dimensions (can be more than one) and fixed order for direct access.
a LList has dynamic size and dynamic order in only one dimension for sequential access.
a Structure is nothing in opposide to an Array.
you can put structured elements into an array as well as into a List.
the main difference is between Arrays and LLists:
an Array has fixed Dimensions (can be more than one) and fixed order for direct access.
a LList has dynamic size and dynamic order in only one dimension for sequential access.
oh... and have a nice day.