Try a PLC free — no signup
String OperationsIntermediateIEC 61131-3

LEFT (Left String Extract)

Extracts a specified number of characters from the beginning of a string.

The LEFT function extracts a specified number of characters from the beginning (left side) of a string. It is used for parsing fixed-format data, extracting prefixes, and processing communication messages where specific fields are at known positions from the start of the string.

Parameters

Inputs

NameTypeDescription
INSTRINGSource string
LINTNumber of characters to extract from left

Outputs

NameTypeDescription
OUTSTRINGExtracted substring

Structured Text Example

// Extract device code from 'DEV001-MOTOR-A'
Device_Code := LEFT(IN := Device_ID, L := 6);  // Result: 'DEV001'

// Extract date from formatted string
Date_Part := LEFT(IN := DateTime_Str, L := 10);  // '2025-01-15'

Free · no signup to try

Run this block in your browser

Try the instruction on a live rung before you copy it into a project — nothing to install.

Try it in your browser — no signup

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad

Platform-Specific Implementation

S

Siemens (TIA Portal)

Use LEFT instruction in TIA Portal.

AB

Allen-Bradley (Studio 5000)

Use MID instruction with starting position 1.

C

CODESYS

Use LEFT() function in ST.

Common Applications

  • Fixed-format data parsing
  • Device code extraction
  • Protocol header parsing
  • Barcode prefix extraction

Frequently Asked Questions

What is LEFT (Left String Extract) in PLC programming?

Extracts a specified number of characters from the beginning of a string. The LEFT function extracts a specified number of characters from the beginning (left side) of a string. It is used for parsing fixed-format data, extracting prefixes, and processing communication messages where specific fields are at known positions from the start of the string.

What are common applications of LEFT (Left String Extract)?

LEFT (Left String Extract) is commonly used for: Fixed-format data parsing, Device code extraction, Protocol header parsing, Barcode prefix extraction.

How do I use LEFT (Left String Extract) in different PLC platforms?

Siemens: Use LEFT instruction in TIA Portal. Allen-Bradley: Use MID instruction with starting position 1. CODESYS: Use LEFT() function in ST.

Free · no signup to try

Wire this block up and run it

Drop the instruction into a rung, press Run and watch it execute in your browser — then adapt it to your vendor tool.

Try it in your browser — no signup

Opens plcsimulationsoftware.com — same team

Prefer ready-made code? Ladder Logic Pack — $29 on Gumroad