String.Mid

Syntax

Mid(Source: String, Start: Integer, [Length: Integer = 0]): String;

Parameters

Source. Source string.

Start. Number of the source string position, from which the returned substring should start.

Length. Number of characters in the returned substring.

Description

The Mid method returns substring of the specified length, which starts with the specified position number of source string.

Comments

Numbering of characters in a string starts with one.

If the Length parameter is equal to 0, the returned substring contains all characters from the specified position to the end of the source string.

Example

Sub UserProc;
Var
    s1, s2: String;
    i1, i2: Integer;
Begin
    s1 := 
"Calculator";
    i1 := 
2;
    i2 := 
4;
    
// Get string
    s2 := String.Mid(s1, i1, i2);
    Debug.WriteLine(
"Mid(""" + s1 + """" + ", " + i1.ToString + ", " + i2.ToString + ") = " + s2);
End Sub UserProc;

After executing the example four characters of the Calculator string starting with the second character are displayed in the console window.

See also:

String