Skip to main content

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

Parameters

NameTypeCommentKind
indexUDINTthe index to replace the object atinput
withObjectCNM_AbstractObject.IObjectthe object to be at this index insteadinput

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