[Visualization]Table element with variable-length array

FPawlak
2020-10-23
2020-10-23
  • FPawlak - 2020-10-23

    Hi,
    I wonder if it is possible to make table with dynamic number of rows.
    Normally if I use as 'data array'

    _array : ARRAY[0..9] OF INT;
    

    I will have table with 10 rows - always with 10 rows (unless I set 'Max. array index' to lower value)
    I want to make it more dynamic. I try:

    _array : ARRAY[*] OF INT; //in VAR_IN_OUT declaration of Visualisation
    _array : POINTER TO INT; //in VAR_IN_OUT declaration of Visualisation
    

    But I alway got only one row. I have tried to set 'Max. array index' to eg. 5,
    manually set column template -> 'Text variable' set to '_array[INDEX]'. But it does not work unfortunately.

    Do you have any idea if it is possible? Or I can only use constant size tables?
    Thanks for your help.

     
  • JAPIB

    JAPIB - 2020-10-23

    Hi,
    When I use an Array like yours : Myarray : ARRAY[0..9] OF INT;
    And I set 'Max. array index' to 2, I got 4 lines in the table.
    You can also :
    - use a variable (for example : diIndexAff) as 'Max. array index and It works dynamically.

    • calulate the value of the variable like this :
      VAR
      diIndexAff:DINT;
      END_VAR
      (Max value calculation minus 2)
      diIndexAff:=UPPER_BOUND(Myarray,1)-2;

    I did not try with the second try (_array : ARRAY[*] OF INT;).

    Hoping to help you.
    BR.

     

Log in to post a comment.