Learn PLCs free
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'

20 Production-Ready Ladder Logic Templates

Stop writing the same rungs from scratch. Get copy-paste-ready templates for motor control, PID loops, safety interlocks, conveyors, and more.

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.

Stop Writing Ladder Logic From Scratch

Get 20 production-ready ladder logic templates for $29 -- download instantly and use them on your next project today.

20
Ready-Made Templates
LD + ST
Both Languages Included
$29
One-Time Purchase
Get Instant Access -- $29

Instant download - 30-day money-back guarantee - Use on unlimited projects

Free PLC simulator

Wire this block up and run it

Drop the instruction into a rung, hit Run, and watch it execute in your browser. 12 guided lessons across 8 PLC dialects — free account, no credit card.

Practice PLCs free →