LEFT - Return the left part of a string

Help Contents

Introduction

Returns the left-most n characters of a string.

Syntax

Informal Syntax:

LEFT( In, L )

Formal Syntax:

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

Parameters

ParameterTypeDescription
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 left-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.

Examples

ExampleReturn Value
LEFT('', 2)STRING#''
LEFT('There', 3)STRING#'The'
LEFT(In:="Ending", L:=3)WSTRING#"End"

Standards Compliance

IEC 61131-3 Second Edition: Table 29.2.

IEC 61131-3 Third Edition: Table 34.2.

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.

Glossary

For the meaning of terms used in Fernhill SCADA.