[Implemented] CountArray() ?

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

[Implemented] CountArray() ?

Post by Flype »

Since we can pass an Array (and LinkedList) to a procedure
it might be useful to be able to retrieve the number of elements of the array inside the procedure.

it could be done with :

Code: Select all

Macro CountArray(array) 
  ( PeekL( @array-8 ) ) 
EndMacro
but it's not 'future proof', so a builtin commands would be nice, no ?


example :

Code: Select all

Macro CountArray(array) 
  ( PeekL( @array-8 ) ) 
EndMacro

Procedure MyProc(UserArray.l(1))
  
  Protected nElement.l = CountArray(UserArray())
  
  Debug nElement
  
EndProcedure

Dim test.l(123)

MyProc(test())
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer