array actual element count

charles.rooscharles.roos Member Posts: 60
How can i determine how many non-empty elements are there in text array? The array doesn't contain empty elements within non-empty elements.

For example I declared an array called "ArrayCurrCode" with type Code and Dimensions=100, then i runned following code:
ArrayCurrCode[1] := 'EUR';
ArrayCurrCode[2] := 'USD';

And now there is 2 non-empty elements, but is there any function that i can use to get this count 2? Or should i programmatically do such function?

Comments

  • DenSterDenSter Member Posts: 8,305
    I thought that ARRAYLEN did the trick, but that returns the variable definition. I'm afraid you'll have to program this. What you could do though, if you only want to know the count, is do a COMPRESSARRAY before you loop through, so you can exit the loop when you come to an empty element.
  • charles.rooscharles.roos Member Posts: 60
    DenSter wrote:
    I thought that ARRAYLEN did the trick, but that returns the variable definition. I'm afraid you'll have to program this. What you could do though, if you only want to know the count, is do a COMPRESSARRAY before you loop through, so you can exit the loop when you come to an empty element.

    Yes, ARRAYLEN returns the value from Dimension attribute when you declare the array, so it is not the right thing for me.
    Seems i have to loop through the array myself.
  • XypherXypher Member Posts: 297
    Have you tried COMPRESSARRAY ? :D
Sign In or Register to comment.