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

Using variable length arrays in libraries

drgry
2017-07-10
2017-07-10
  • drgry - 2017-07-10

    Hello all,

    I am trying to make a FB in library that uses variable length arrays as input. I am facing some issues I would like to get answers to. I attached .zip of library and test project. From this you can see following:

    1. Codesys online help states that: CODESYS supports one, two, and three-dimensional arrays of ELEMENTATY data types. Contrary to this I am able to define variable length arrays of user defined data type with 2 REAL elements and to define FB . Code compiles with no error and it is possible to install library in Library repository. There is no documentation generated, but I found explanation to this in forum . Library has namespace DRGRY.

    2. For testing two more FB are defined: with variable length array of Real and with fixed length array of . Again, code compiles with no error and it is possible to install library in Library repository.

    3. Testing in project: Now the fun begins: When I try to call in program with as VAR_IN_OUT parameter compiler gives me error: . Why? I copied this function from library to project with one necessary modification: declaration of input variable is no longer but . When calling this function with there is no problem. Code executes just fine on my Beaglebone Black. Only problem is converting to . For me this means that I can not put function with varianle length array of DUT to library.

    Questions:

    1. Despite online help claiming that only variable length arrays of elementary types can be used, it is clear that variable length arrays of DUT can be used when defining FB. Is this legal to do with Codesys?

    2. How to make it work with library defined DUT and FB, with regard to errors I am getting? Am I doing something wrong? Is there any settings to do? Is this a system problem?

    I am using latest(?) version of Codesys V3.5 SP10 Patch 4.

    I would appreciate some help and guidelines on this matter.

    Best regards

    ArrayTest.zip [74.12 KiB]

     
  • yannickasselin1 - 2017-07-10

    I've been having problems with variable arrays.
    I stopped using it and used pointers instead.
    See this post for more information on the problems I had:
    l viewtopic.php?t=7558#p17267 l

     

Log in to post a comment.