replaceObjectAt
Short summary
This method replaces the Interface reference inside the collection at the given index with the given Interface. Example: A list of: 1 2 3 after list.replaceObjectAt(1, withObject:=4) will become: 1 4 3 and return SingleExecutionResult.SUCCESS Example 2: A list of: 1 2 3 after list.replaceObjectAt(3, withObject:=4) will remain: 1 2 3 and return SingleExecutionResult.ERROR
Return: SingleExecutionResult.SUCCESS: index valid, element at index replaced with withObject
SingleExecutionResult.ERROR: ìndex out of bounds, nothing changed
SingleExecutionResult.Aborted: withObject wasn't valid
- Return type: CNM_ReturnTypes.SingleExecutionResult
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| index | UDINT | the index to replace the object at | input |
| withObject | CNM_AbstractObject.IObject | the object to be at this index instead | input |
Code
Declaration
METHOD replaceObjectAt :CNM_ReturnTypes.SingleExecutionResult
VAR_INPUT
(*the index to replace the object at*)
index :UDINT;
(*the object to be at this index instead*)
withObject :CNM_AbstractObject.IObject;
END_VAR