Skip to main content

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

Parameters

NameTypeCommentKind
indexUDINTthe index to insert the object atinput
objectCNM_AbstractObject.IObjectthe object to be addedinput

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