Editar

Compartir a través de


BigText.TextPos(Text) Method

Version: Available or changed with runtime version 1.0.

Gets the position at which a specific string first occurs in this BigText instance.

Syntax

Position :=   BigText.TextPos(String: Text)

Parameters

BigText
 Type: BigText
An instance of the BigText data type.

String
 Type: Text
The text string to search for in the BigText variable. If this parameter is empty, then 0 is returned.

Return Value

Position
 Type: Integer
The position at which a specific string first occurs in this BigText instance.

Remarks

The first character in a BigText variable is position 1.

Example 1

The following examples show how to use the TextPos Method. These examples require that you create the following global variables and text constant.

var
    MyBigText: BigText;
    VarPosition: Text;
    Text000: Label 'VarPosition = %1';

The following examples first initialize the content of the BigText variable with the text ABCDEFG.

In this example, the first occurrence of the character B (the first character of the specified text) is found in the second position in the MyBigText variable so the method returns 2. The return value is stored in the variable VarPosition and displayed in a message box.

MyBigText.AddText('ABCDEFG');  
VarPosition := MyBigText.TextPos('BCD'); // Returns 2.  
Message(Text000, VarPosition);  

Example 2

In the following example, the method returns 0 because the specified string is not found in the MyBigText variable. The return value is stored in the variable VarPosition and displayed in a message box.

MyBigText.AddText('ABCDEFG');  
VarPosition := MyBigText.TextPos(''); // Returns 0.  
Message(Text000, VarPosition);  

Example 3

In the following example, the method returns 0 because the specified string is not found in the MyBigText variable. The return value is stored in the variable VarPosition and displayed in a message box.

MyBigText.AddText('ABCDEFG');  
VarPosition := MyBigText.TextPos('XYZ'); // Returns 0.  
Message(Text000, VarPosition);  

BigText Data Type
Get Started with AL
Developing Extensions