Adding Local Variables to a Runnable or Method

  1. Open the signature editor for the runnable or method.
  2. Go to the Locals tab of the signature editor.
  3. 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.

  4. Enter a name for the local variable.
  5. In the Local Variable Type combo box, select a type for the local variable.

    Note

    From ASCET V6.4.0 on, complex local variables (except records) are always explicit references. Composite local variables (i.e. arrays and matrices) and local variables of record type can be specified as instances or explicit references.

    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.

  6. If you selected an array or matrix of enumeration or record type, Closedthe following happens.

    The Choose a enumeration type or Choose a record type window opens.

    • In the "Database"/"Workspace" field, select the enumeration or record you want to use, then click OK.
  7. To edit the size of an array or matrix selected as local variable, Closeddo the following.

    1. Open the Argument menu or the context menu and select Edit Max Size.

      The Max and Variant Size for: <argument> window opens.

    2. In the Max Size x (and Max Size y) field(s), enter the array or matrix size.
    3. To specify a variant size, use the Variant Size x (and Variant Size y) field(s) to select the system constants you want to use as dimension values.

      Both normal and user-defined system constants can be used. The value of a system constant should be in the range 1 ... X (or 1 ... Y).

    4. To specify a variable size, use the Variant Size x (and Variant Size y) field(s) to select *.

      The Max Size x (and Max Size y) field(s) are disabled.

    5. Click OK to close the window and accept your settings.

  8. 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:

  9. 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.

  10. 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

Locals Tab

Introduction – Variant Size of Arrays and Matrices

Introduction – Variable Size for Arrays and Matrices

Introduction – Explicit References

Introduction – Constants and System Constants

Reserved Keywords

Editing Arguments and Local Variables

Directions of Method Arguments