Right (open)

Returns the right part of a string.

Syntax

// Core function, no LOADLIB necessary

STRING FUNCTION Right(STRING text, INTEGER numbytes)

Parameters

STRING text

String to return a part from

INTEGER numbytes

Number of bytes to return

Return value

STRING

The requested part of the string

Description

Right returns the last 'n' bytes from a string. If a string contains less than the requested number of bytes, the entire string is returned. When manipulating UTF-8 strings it is recommended that you use the function UCRight because UTF-8 characters can be made up from more bytes and the result is therefore unpredictable.

Examples

// returns 'ef'
STRING example1 := Right("abcdef", 2);

// returns 'ro€'
STRING example2 := Right("euro€", 5);

// returns 'euro€'
STRING example3 := UCRight("euro€", 5);

// returns the entire string, e.g 'abcdef'
STRING example4 := Right("abcdef", 100);

// returns an empty string
STRING example5 := Right("abcdef", -10);