[Implemented] UBound(Array() [, Dimension])

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

[Implemented] UBound(Array() [, Dimension])

Post by BackupUser »

Restored from previous forum. Originally posted by Lars.

I miss a Ubound() funktion very much. It should return the number of
indexes in a Array in the specifed Dimension.

THX,

Lars
PS: Sorry for my broken English

(Implemented as 'ArraySize()')

Lars
IF ALL SEEMS PERFECT, CHECK IT AGAIN. TWICE.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by GPI.

I don't know, what you want.
Make a little example.

PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by GPI

I don't know, what you want.
Make a little example.
It is a Visual Basic command. If you do something like this:

Dim foo.l(20)
PrintN(Str(UBound(foo)))

then it will print 21.


--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Lars.

And
Dim foo.l(20,23,25)
printN(Ubound(Foo(),1)
printN(Ubound(Foo(),2)
printN(Ubound(Foo(),3)

Will print 21, 24, 26.


Lars
IF ALL SEEMS PERFECT, CHECK IT AGAIN. TWICE.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by GPI.

This would be make only tense, when after a redimension the dim wont delteted.

For LinkedList exist a command
CountList(LinkedList())

GPI

PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

As workaround you could code like I do:

Code: Select all

Dim Array.l(16)
Array(0) = 16
This Array has 17 entries - from 0 to 16.
Now for my data I use only 1 to 16, because 0 is used for the number of the possible entries = 16 (from 1 to 16).
This:

Code: Select all

Result = Array.l(0) 
would be the equivalent of your UBound command.
If you use your array for loops you have to start at 1 instead of 0.

Have a nice day...

Franco
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Lars.

@ franko

I thought with Purebasic would the time of improvising end.
I was in an error :cry::evil:.



Lars
IF ALL SEEMS PERFECT, CHECK IT AGAIN. TWICE.
Post Reply