Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Array finding the total of index

  • dumbass - 2022-11-25


    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;
    Count := Count + 1;

    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.