Adding Local Variables to a Runnable or Method
- Open the signature editor for the runnable or method.
- Go to the Locals tab of the signature editor.
Do one of the following:
Click the
Add local variable button. In the Local Variable menu, select Add.
A new local variable is added to the Locals list.
- Enter a name for the local variable.
In the Local Variable Type combo box, select a type for the local variable.
The type <user defined> is used to add components and enumerations as runnable- or method-local variable.
An array is created with max. size x = 4, a matrix is created with max. size x = max. size y = 3.
Note
If you use matrices as interrunnable variables, make sure that the Number of dimensions for fixed matrixestarget option is set to Two-dimensional.
Otherwise, a warning WMdl653 is issued during AUTOSAR code generation. By default, this warning is promoted to an error.
If you selected an array or matrix of enumeration or record type,
the following happens.To edit the size of an array or matrix selected as local variable,
do the following.Enter a comment and a unit for the variable.
If you selected an array, matrix, or record as type, an additional step may be necessary:
Activate (deactivate) the Reference option to mark the local variable as explicit reference (instance).
Note
You can export models that use non-scalar method-/runnable-local variables marked as instances only in AMD format V6.4.0 or higher. An AMD format V6.3.* or older will result in an export error.
- If you selected an array, matrix or component as type, use the Read for Referenced Element and Write for Referenced Element options to set internal access to the referenced element to Read, Write, or both.
Note |
|---|
Non-scalar local variables specified as instances must be initialized before they are read. For method-/runnable-local records marked as instances, the separate assignment to each record element is recognized as initialization. The expression must only contain accesses to record elements that are already initialized. Assigning each element of an array or matrix is recognized as initialization. Passing a local variable of array, matrix or record type as Out argument is recognized as initialization. |
See also
Editing the Signature of a Runnable or Method
Introduction – Variant Size of Arrays and Matrices
Introduction – Variable Size for Arrays and Matrices
Introduction – Explicit References
Introduction – Constants and System Constants