Changes between Initial Version and Version 5 of Ticket #5526


Ignore:
Timestamp:
2019-06-12T21:41:42Z (6 years ago)
Author:
Per Östlund
Comment:

Fixed code markup.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #5526 – Description

    initial v5  
    22
    33Example:
    4   uniontype Index
    5     record INDEX
    6       list<Integer> idx;
    7     end INDEX;
    8   end Index;
     4{{{#!mo
     5uniontype Index
     6  record INDEX
     7    list<Integer> idx;
     8  end INDEX;
     9end Index;
    910 
    10   uniontype Compo
     11uniontype Compo
    1112  record COMPO
    1213    array<Real> co;
    1314  end COMPO;
    14   end Compo;
    15 
     15end Compo;
     16}}}
    1617Supposed we have a Compo called compo and an Index called index, the for loop gives wrong array components:
    17 
     18{{{#!mo
    1819for k in index.idx loop
    19  print(String(k));
    20  r := compo.co[k];
     20  print(String(k));
     21  r := compo.co[k];
    2122end for;
    22 
     23}}}
    2324The print command gives the correct number, but k as array index
    2425seems to have twice the value of the list member. So if it exceeds the array bounds we will see an error otherwise r has a wrong value.