Page 1 of 1
Size Of Arrays
Posted: Fri Aug 08, 2008 1:16 pm
by PureNewbie
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.
Posted: Fri Aug 08, 2008 1:26 pm
by srod
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.
Posted: Fri Aug 08, 2008 2:00 pm
by Thalius
for now either in a macro or however you like it:
Getting the Size of an Array():
Cheers,
Thalius
Re: Size Of Arrays
Posted: Fri Aug 08, 2008 2:09 pm
by Little John
PureNewbie wrote:I understand that PureBasic can use linked lists and collections instead of simple one dimensional arrays,
What are "collections"? Am I missing something?
Regards, Little John
Size Of Arrays
Posted: Fri Aug 08, 2008 4:28 pm
by PureNewbie
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 .......).
Re: Size Of Arrays
Posted: Fri Aug 08, 2008 4:54 pm
by Little John
PureNewbie wrote:My apologies to Little John - for "collections" read "structures"
Ah, I see. No problem.
Regards, Little John
Posted: Fri Aug 08, 2008 4:58 pm
by Kaeru Gaman
@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.