LEFT

Returns the leftmost characters of a string.

Signature

    ┌─────────┐
IN ─┤         │
    │  LEFT   ├─ OUT
 L ─┤         │
    └─────────┘
FUNCTION LEFT : ANY_STRING
  VAR_INPUT
    IN : ANY_STRING;
    L  : ANY_INT;
  END_VAR
END_FUNCTION

The return type matches the type of IN. LEFT accepts STRING for IN; L is INT.

Inputs

Name

Type

Description

IN

ANY_STRING

The source string.

L

INT

Number of leftmost characters to return.

Outputs

Name

Type

Description

Return value

ANY_STRING

The leftmost L characters of IN. Same type as IN.

Description

Returns the leftmost L characters of IN. If L is greater than or equal to the length of IN, the entire string is returned.

Example

result := LEFT('Hello', 3);    (* result = 'Hel' *)
result := LEFT('Hi', 10);      (* result = 'Hi' *)

See Also

  • RIGHT — right substring

  • MID — middle substring

  • LEN — string length

References