0

Codesys has a nice (IMO) feature where comments adjacent to a variables declaration are shown in the table view when online which makes it easier for others to understand original programmers intent.

It would be very nice if there was some way to add a similar comment for individual elements of an array to indicate a specific meaning. Anyone know if this can be accomplished?

Dave
  • 142
  • 7
  • If in array every element is individual may be you can use pointers. Define variables individually and then make array and point to those variables. – Sergey Romanov Apr 13 '18 at 06:49
  • I have a multi dimensional array that tracks parts throughout various stages of manufacturing process, each process is 1 index of array, each part within process simultaneously is 2nd index. It would have been nice to comment certain key stages to make it easier for maintenance . I think arrays are the simpler solution in this case and pointers would add more complexity. Thanks for the suggestion though. – Dave Apr 17 '18 at 08:18
  • Then you can go with Enumerations. See why it is important to describe your problem in a whole. Do you use `CASE`? Please add more info to your question, perhaps, there is completely different solution than what you think. – Sergey Romanov Apr 18 '18 at 05:53

1 Answers1

0

I think it's not possible to comment array in that way. Perhaps multi-line comments would help a little bit?

In the variable declaration:

PROGRAM MAIN
VAR
    TestArray : ARRAY[1..10] OF BOOL;   (*Test array
                                            1: Run
                                            2: Error
                                            3: Starting allowed
                                            4: Etc.
                                        *)
END_VAR

Then in online view (at least TwinCAT 3, which is codesys based), it will show all the lines when hovering the mouse on the icon: enter image description here

Quirzo
  • 1,183
  • 8
  • 10
  • Thanks, I do this already, was hoping could go a bit further but thanks for the reply anyway – Dave Apr 17 '18 at 08:15