Directions of Method Arguments
Since ASCET 6.0, the attribute Direction is available for method arguments. This attribute can be set in the Arguments tab of the signature editor. The argument direction determines access semantic for the argument as well as the way parameters are passed. The latter can be different for value types and reference types (see Value Types and Reference Types).
Available directions and their properties are summarized in the following table.
In | read only | by value | by reference |
Out | write only | by reference | by reference |
InOut | read and write | by reference | by reference |
The following must be kept in mind when setting the direction:
- Default direction for arguments of value type.
- In arguments can be read in the method. An error is produced for each write access to an In argument.
- In arguments get the value from the expression passed to the invoked method.
- Default direction for arguments of reference type.
- InOut arguments can be read and written in the method.
- InOut arguments must be initialized before they are passed to the invoked method.
- If an InOut argument is only read, or only written, in the method, you are informed that you can change the direction to In, or Out.
- Since an InOut argument can be written, and its value passed to the calling entity, only variables can be assigned to InOut arguments. Parameters, the output of a calculation, etc., are not allowed.
- Out arguments can be written in the method. An error is produced for each read access to an Out argument.
- Out arguments need not be initialized before they are passed to the invoked method. They are considered initialized for the code following the invocation.
- All Out arguments must be written before the method is exited. An error is produced if one or more Out arguments is not written.
- Since an Out argument must be written, and its value is passed to the calling entity, only variables can be assigned to an Out argument. Parameters, the output of a calculation, etc., are not allowed.
- Classes cannot be used as Out arguments.
See also
Arguments Tab
Value Types and Reference Types
Adding an Argument to the Method