Array finding the total of index

dumbass
2022-11-25
2023-03-03
  • 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

     
  • ben1 - 2023-03-03

    Count := 0;

    FOR i:=(First element of array eg.0) TO (Last element of array eg.10) DO
    IF String[i] = '' THEN
    Count := Count;
    ELSE
    Count := Count + 1;
    END_IF;
    END_FOR;

    This will add 1 to the 'Count' in each instance that the String has any value other than NULL in it.

     

Log in to post a comment.