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
| Name | Type | Description |
|---|---|---|
| IN | STRING | Source string |
| L | INT | Number of characters to extract from right |
Outputs
| Name | Type | Description |
|---|---|---|
| OUT | STRING | Extracted 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
Siemens (TIA Portal)
Use RIGHT instruction in TIA Portal.
Allen-Bradley (Studio 5000)
Use MID instruction with calculated starting position.
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.
Related Function Blocks
LEFT (Left String Extract)
Extracts a specified number of characters from the beginning of a string.
View Reference →CONCAT (String Concatenation)
Joins two or more strings into a single combined string.
View Reference →FIND (String Search)
Finds position of a substring within a string; returns 0 if not found.
View Reference →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.
Instant download - 30-day money-back guarantee - Use on unlimited projects