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

VAR_OUTPUT

Eager
2017-12-29
2018-01-25
  • Eager - 2017-12-29

    I made a FB type and do some calculation on some array inside the FB.
    I would like to expose this array to the "parent" POU.
    Currently the array is defined inside a VAR block (like MyArray:ARRAY[0..99] OF WORD)).
    Is it possible to make this variable visible from outside by some attribute or something similar?
    Alternatively, can a pointer to an array defined outside the FB be used instead of a local variable?

     
  • Joan M - 2018-01-25

    You've answered yourself in the subject of your question...

    From the external part of the code you can write something like yourfunctionblockInstance.YourArray to access the array freely.

    If the array declaration is in the normal var or var_output areas you'll not be able to modify it from outside (which is always a good thing regarding design and peace of mind when you are programming).
    If you want to modify that array from outside you have to declare it in the VAR_INPUT area.

    Of course another approach would be using a pointer and pointer arithmetics to find the next positions of the array like you'd do in any high level language.

    Good luck!

     

Log in to post a comment.