Array finding the total of index

dumbass
2022-11-25
2022-12-01
  • dumbass - 2022-11-25

    Hello,

    I have an array of String but I do not know how many elements in it. If the user put 3 elements in the array then the total of index = 3. How can I scan all the elements array if it is not equal to '' (meaning NULL) and get the total of index in the array?
    Thank you in advance

     
  • kislov - 2022-11-25

    Use FOR loop.

    uiIndex := 0;
    
    FOR i := LOWER_BOUND(asArrayOfStrings[i], 1) TO UPPER_BOUND(asArrayOfStrings[i], 1) DO
    
        IF asArrayOfStrings[i] <> '' THEN
           uiIndex := uiIndex + 1;
        END_IF
    
    END_FOR
    
     
    πŸ‘
    2
  • hermsen

    hermsen - 2022-11-26

    Another possibility would be to write a class around the array of strings which does the housekeeping for you.

    the main advantage is that your housekeeping code is neatly placed in a single spot.

     
  • hermsen

    hermsen - 2022-11-26

    Another possibility would be to write a class around the array of strings which does the housekeeping for you.

    the main advantage is that your housekeeping code is neatly placed in a single spot.

     
  • dumbass - 2022-12-01

    Thank you, sir.

     

Log in to post a comment.