Learn PLCs free
String OperationsIntermediateIEC 61131-3

RIGHT (Right String Extract)

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

The RIGHT function extracts a specified number of characters from the end (right side) of a string. It is used for extracting suffixes, file extensions, trailing identifiers, and any data positioned at the end of a fixed-format string.

Parameters

Inputs

NameTypeDescription
INSTRINGSource string
LINTNumber of characters to extract from right

Outputs

NameTypeDescription
OUTSTRINGExtracted substring

Structured Text Example

// Extract unit number from 'MOTOR-A'
Unit_ID := RIGHT(IN := Motor_Name, L := 1);  // Result: 'A'

// Extract checksum from message
Checksum := RIGHT(IN := Message, L := 4);

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 RIGHT instruction in TIA Portal.

AB

Allen-Bradley (Studio 5000)

Use MID instruction with calculated starting position.

C

CODESYS

Use RIGHT() function in ST.

Common Applications

  • Suffix extraction
  • Trailing identifier parsing
  • Checksum extraction
  • File extension parsing

Frequently Asked Questions

What is RIGHT (Right String Extract) in PLC programming?

Extracts a specified number of characters from the end of a string. The RIGHT function extracts a specified number of characters from the end (right side) of a string. It is used for extracting suffixes, file extensions, trailing identifiers, and any data positioned at the end of a fixed-format string.

What are common applications of RIGHT (Right String Extract)?

RIGHT (Right String Extract) is commonly used for: Suffix extraction, Trailing identifier parsing, Checksum extraction, File extension parsing.

How do I use RIGHT (Right String Extract) in different PLC platforms?

Siemens: Use RIGHT instruction in TIA Portal. Allen-Bradley: Use MID instruction with calculated starting position. CODESYS: Use RIGHT() 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 →