You are here: Core Reference > Coding > Logic > LEFT

LEFT

Function Name

LEFT

Description

Outputs a specific number of characters taken from a string input. The characters are taken from the left-hand side of the input string (starting with the first character).

Arguments

IN {STRING}

The IN input is a string input. The LEFT function uses characters from the IN input for its output.

L {INT}

Defines the number of characters in the IN input that are used for the output. The output begins with the first character of the IN input and continues for the L amount of characters.

For more information on the data types for the inputs and outputs, see Data Type Hierarchy.

Returns

Output {STRING}

The output is a string that is the L number of characters from the IN string, starting from the left.

Example:

Function Block Diagram - LEFT:

In this example, the IN input is 'PIPELINE STRUCTURE FAILURE' and the L input is 18. This means that the LEFT function will return 18 characters from the IN input, starting with the left-most character (the first character). So, as the IN input is 'PIPELINE STRUCTURE FAILURE', the LEFT function outputs 'PIPELINE STRUCTURE' (the first 18 characters from the IN string).

ST Program - LEFT:

To use a LEFT function in an ST program, you need to use this syntax:

  • Output := LEFT ('IN', L);>

Where Output, IN and L are defined as variables earlier in the ST program.

Alternatively, you can use the following syntax:

  • Output := LEFT (IN:= 'PIPELINE STRUCTURE FAILURE', L:= 18);

Where the 'PIPELINE STRUCTURE FAILURE' and 18 values are the input values (in this case, they are the same values as used in the Function Block Diagram example above).


ClearSCADA 2015 R2