MID (Extract Substring)
Extracts L characters from string IN starting at 1-based character position P and writes the substring to the target STRING variable.
Description
MID slices length (L) characters from src (IN) starting at index pos (P, where 1 is the first character).
In modular equipment sequences, MID({cmd}, 1, {idx}) extracts one operation code at a time from a multi-step command string such as "ER" or "ODCU1DOUC2".
Syntax
- variable_name: Target
STRINGvariable - qualifier: Typically
ActionQualifier.P(Pulse) - instruction:
ActionInstruction.MID - src (
IN): SourceSTRINGvariable or literal - length (
L): Number of characters to extract (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 -> MID and choose the P qualifier.
- Fill in the target
STRINGvariable, source string (IN), character count (L), and 1-based start position (P).
Python
from automation_machine import ActionQualifier, ActionInstruction
step.add_action("{op}", "Extract current operation", qualifier=ActionQualifier.P, instruction=ActionInstruction.MID, src="{cmd}", length="1", pos="{idx}")