Insert String (INSERT)
This information applies to the
CompactLogix
5370, ControlLogix
5570, Compact GuardLogix
5370, GuardLogix
5570, Compact GuardLogix
5380, CompactLogix
5380, CompactLogix
5480, ControlLogix
5580, and GuardLogix
5580 controllers.Use the INSERT instruction to add ASCII characters to a specified location within a string.
Available Languages
Ladder Diagram
Function Block
Structured Text
INSERT (SourceA,SourceB,Start,Dest);
Operands
There are data conversion rules for mixed data types within an instruction. See Data conversions. The INSERT instruction uses the following operands.
Ladder Diagram and Structured Text
Operand | Type | Format | Description | Notes |
---|---|---|---|---|
Source A | String type | Tag | String to add the characters to | String types are default STRING data types or any new string types you create |
Source B | String type | Tag | String containing the characters to add | |
Start | SINT DINT | Immediate tag | Position in Source A to add the characters | Enter a number between 1 and the DATA size of the Source. |
Destination | String type | Tag | String to store the result |
See Structured Text Syntax for more information on the syntax of expressions within structured text.
Description
The INSERT instruction adds the characters in Source B to a designated position within Source A and places the result in the Destination.
- Start defines where in Source A that Source B is added.
- Unless Source A and the Destination are the same tag, Source A remains unchanged.
Affects Math Status Flags
No
Major/Minor Faults
Type | Code | Cause | Recovery Method |
---|---|---|---|
4 | 51 | The LEN value of the string tag is greater than the DATA size of the string tag. |
|
4 | 56 | The Start or Quantity value is invalid. | Check that the Start value is between 1 and the DATA size of the Source. |
Execution
Ladder Diagram
Condition | Ladder Diagram Action |
---|---|
Prescan | The rung-condition-out is set to false. |
Rung-condition-in is false | The rung-condition-out is set to false. |
Rung-condition-in is true | The instruction executes.
The rung-condition-out is set to true. |
Postscan | The rung-condition-out is set to false. |
Execution
Structured Text
Condition | Action |
---|---|
Prescan | See Prescan in the Ladder Diagram table |
Normal execution | See rung-condition-in is true in the Ladder Diagram table. |
Postscan | See Postscan in the Ladder Diagram table |
Example
When
temp_high
is set, the INSERT instruction adds the characters in string_2
to position 2 within string_1
and places the result in string_3
.Ladder Diagram
Structured Text
IF temp_high THEN
INSERT(string_1,string_2,2,string_3);
temp_high := 0;
END_IF;
Provide Feedback