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

Find how many elements filled inside an array

androidzz
2022-12-02
2023-01-10
  • androidzz - 2022-12-02

    Hi,

    I have an array: aTelemetry: ARRAY[0..65536] OF BYTE;
    I put data inside this array. the amount of elements filled inside this array can be variable all the time.

    I want to publish this array via mqtt but if i publish the whole array i get alot of blanc data/white spaces as data. So i only want to send SIZEOF(aTelemetry) without empty elements.
    suppose I fill the array with 60000 bytes, then I don't want to include the last 5536 Bytes.

    So the question; is there a function/manner to see how much of the array is filled with written data?

    kind regards

     
  • nothinrandom - 2023-01-10

    When you're filling out this array, couldn't you just keep track of the filled index via a separate variable? This is especially important if you're re-using this array since each transaction might not have the same size.

     

Log in to post a comment.