-
-
November 12, 2024 at 7:09 pmjeremy.rutmanSubscriber
I can replace the element at a fixed index of an array using the Assign of Structured Element Array Operator.Â
However I need to replace the Nth element, where N is an input to my function - when I try this (using N instead of some constant) I hitÂType Error ERR_105 Not a size expression at REFRESH_CMD_TIMEOUT/_L21=Â
Identifier N should be bound to a static size expressionÂ
Can someone let me know if a. this is possible, and b. if possible, how to proceed
-
November 12, 2024 at 8:31 pmjeremy.rutmanSubscriber
For the Assign of Structured Element hidden parameter (the index) you can set [N] in the parameters box at the bottom.Â
Why this allows you to now use dynamic index is a mystery to me. If you go out of the array bounds nothing happens, so apparently Scade knows not to write past array bounds.Â
But if it knows how to do that then why throw the 'Identifier N should be static' that started me on this little journey? -
December 4, 2024 at 1:05 pmBenjamin DescorpsAnsys Employee
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. <
>). Example: function #pragma kcg expand #end F1 <
>( i : int16 ^10; Â v : int16) returns (Â o : int16 ^10)
  o = (i with [idx] = v);F1 will then be instantiated with a static size:
Hope this helps,
Benjamin
Â
-
- You must be logged in to reply to this topic.
-
1161
-
488
-
486
-
225
-
201
© 2024 Copyright ANSYS, Inc. All rights reserved.