TextConst data type

Version: Available or changed with runtime version 1.0.

Denotes a multi-language string constant.

Instance methods

The following methods are available on instances of the TextConst data type.

Method name Description
Contains(Text) Returns a value indicating whether a specified substring occurs within this string.
EndsWith(Text) Determines whether the end of this string instance matches the specified string.
IndexOf(Text [, Integer]) Reports the one-based index of the first occurrence of the specified string in this instance.
IndexOfAny(Text [, Integer]) Reports the one-based index of the first occurrence of the specified string in this instance. The search starts at a specified character position.
IndexOfAny(List of [Char] [, Integer]) Reports the one-based index of the first occurrence in this instance of any character in a specified array of Unicode characters. The search starts at a specified character position.
LastIndexOf(Text [, Integer]) Reports the one-based index position of the last occurrence of a specified string in this instance.
PadLeft(Integer [, Char]) Returns a new Text that right-aligns the characters in this instance by padding them on the left, for a specified total length.
PadRight(Integer [, Char]) Returns a new string that left-aligns the characters in this string by padding them with spaces on the right, for a specified total length.
Remove(Integer [, Integer]) Returns a new Text in which a specified number of characters from the current string are deleted.
Replace(Text, Text) Returns a new Text in which all occurrences of a specified string in the current instance are replaced with another specified string.
Split([Text,...]) Splits a string into a maximum number of substrings based on a collection of separators.
Split(List of [Text]) Splits a string into a maximum number of substrings based on a collection of separators.
Split(List of [Char]) Splits a string into a maximum number of substrings based on a collection of separators.
StartsWith(Text) Determines whether the beginning of this instance matches a specified string.
Substring(Integer [, Integer]) Retrieves a substring from this instance.
ToLower() Returns a copy of this string converted to lowercase.
ToUpper() Returns a copy of this string converted to uppercase.
Trim() Returns a new Text in which all leading and trailing white-space characters from the current Text object are removed.
TrimEnd([Text]) Removes all trailing occurrences of a set of characters specified in an array from the current Text object.
TrimStart([Text]) Removes all leading occurrences of a set of characters specified in an array from the current Text object.

Remarks

The TextConst data type is typically used for UI messages; process or error messages. Keeping the TextConst data type in global scope, makes it easier to reuse the same message for several situations. For information about naming, see CodeCop Rule AA0074.

Important

The TextConst data type is not included in the .xlf files for translation. Make sure to use the Label Data Type instead.

Example

The data type can be declared with the syntax as shown in the example below.

codeunit 50100 MyCodeunit
{
    procedure MyProcedure()
    var
        localTextConst: TextConst ENU = 'My text', DAN = 'Min tekst';
    begin
        Message(localTextConst);
    end;

    var
        globalTextConst: TextConst ENU = 'My text', DAN = 'Min tekst';
}

Get Started with AL
Developing Extensions