Ansys Learning Forum › Forums › Discuss Simulation › Embedded Software › Replacing Nth element of array › Reply To: Replacing Nth element of array
Hello,
As indicated by the error message, the "with" predefined Scade operator only accepts static indexes. As the Scade language is mainly used to build critical safety systems, use of dynamic access is very limited to guarantee safety of the code. For dynamic access, the code shall guarantee that the index passed is well in the range of the array size (Example for the dynamic projection).
To answer your need, you may declare a generic operator parameterized by size to change a value of an array. The index of the array element, to be modified is passed as a size parameter (i.e. <
function #pragma kcg expand #end F1 <
  o = (i with [idx] = v);
F1 will then be instantiated with a static size:
Hope this helps,
Benjamin
Â