RIGHT - Return the right part of a string

Help Contents


Returns the right-most n characters of a string.


Informal Syntax:

RIGHT( In, L )

Formal Syntax:

RIGHT( In:=expression, L:=expression )


InANY_STRINGThe input string.
LANY_INTThe number of characters to return.

The function is overloaded and accepts either the STRING or WSTRING type for the In parameter.

Return Value

The return value is a string consisting of the right-most L characters of string In.

The type of the string returned is the same as the In parameter.

If L is greater than the length of the In parameter, the function returns the entire string. If L is zero or negative, the function returns a zero length string.


ExampleReturn Value
RIGHT('Megabit', 3)STRING#'bit'
RIGHT(In:="Kilobit", L:=4)WSTRING#"bit"

Standards Compliance

IEC 61131-3 Second Edition: Table 29.3.

IEC 61131-3 Third Edition: Table 34.3.

Note: The function allows negative values for the L parameter. The IEC 61131-3 standard states this should be an error.

Further Information

String Functions

To learn about other String Functions.

Common Elements

To learn about other IEC 61131-3 Common Elements.


For the meaning of terms used in Fernhill SCADA.