REPLACE (Replace Substring)
Replaces L characters in IN1 starting at 1-based position P with substring IN2, writing the updated string to the target STRING variable.
Description
REPLACE removes length (L) characters from src1 (IN1) starting at 1-based index pos (P), inserts src2 (IN2) at that position, and stores the resulting string in the target variable.
Syntax
- variable_name: Target
STRINGvariable - qualifier: Typically
ActionQualifier.P(Pulse) - instruction:
ActionInstruction.REPLACE - src1 (
IN1): OriginalSTRINGvariable or literal - src2 (
IN2): ReplacementSTRINGvariable or literal - length (
L): Number of characters to replace (INTvariable or literal) - pos (
P): 1-based starting character position (INTvariable or literal)
Sequence Visual Editor
- Select an action on a step or transition and hold Alt (or right-click -> Edit Qualifier & Instruction).
- Select Strings -> REPLACE and choose the P qualifier.
- Fill in the target
STRINGvariable, original string (IN1), replacement string (IN2), length (L), and position (P).
Python
from automation_machine import ActionQualifier, ActionInstruction
step.add_action("status_code", "Update station status char", qualifier=ActionQualifier.P, instruction=ActionInstruction.REPLACE, src1="status_code", src2='"R"', length="1", pos="3")