insertObjectAt
Short summary
This method adds the given object at the given index. Will shift the other data starting at given index to the right. List Lenght will be incremented. Index is valid if it's <= collection.size
Example: A list of: 1 2 3 after list.insertObjectAt(1, object:=4) will become: 1 4 2 3 and return SingleExecutionResult.SUCCESS Example 2: A list of: 1 2 3 after list.insertObjectAt(3, object:=4) will become: 1 2 3 4 and return SingleExecutionResult.SUCCESS Example 3: A list of: 1 2 3 after list.insertObjectAt(5, object:=4) will become: 1 2 3 and return SingleExecutionResult.ERROR
Return: CNM_ReturnTypes.SingleExecutionResult.SUCCESS: insert was successful
CNM_ReturnTypes.SingleExecutionResult.ERROR: insert failed, because container needs to increase but no memory left or index is not in valid range
CNM_ReturnTypes.SingleExecutionResult.ABORTED: NULL object or the list itself was passed
- Return type: CNM_ReturnTypes.SingleExecutionResult
Parameters
| Name | Type | Comment | Kind |
|---|---|---|---|
| index | UDINT | the index to insert the object at | input |
| object | CNM_AbstractObject.IObject | the object to be added | input |
Code
Declaration
METHOD insertObjectAt :CNM_ReturnTypes.SingleExecutionResult
VAR_INPUT
(*the index to insert the object at*)
index :UDINT;
(*the object to be added*)
object :CNM_AbstractObject.IObject;
END_VAR