Text Data Type

Denotes a text string.

The following methods are available on the Text data type.

Method name Description
StrSubstNo(String [, Any,...]) Replaces %1, %2, %3... and #1, #2, #3... fields in a string with the values you provide as optional parameters.
StrPos(String, String) Searches for the first occurrence of substring inside a string.
StrLen(String) Gets the length of a string you define.
IncStr(String) Increases a positive number or decrease a negative number inside a string by one (1).
CopyStr(String, Integer [, Integer]) Copies a substring of any length from a specific position in a string (text or code) to a new string.
MaxStrLen(String) Gets the maximum defined length of a string variable.
MaxStrLen(Variant) Gets the maximum defined length of a variant variable. Calling this method always results in a run-time exception.
PadStr(String, Integer [, String]) Changes the length of a string to a specified length. If the string is shorter than the specified length, length spaces are added at the end of the string to match the length. If the string is longer than the specified length, the string is truncated. If the specified length is less than 0, an exception is thrown.
DelChr(String [, String] [, String]) Deletes chars contained in the which parameter in a string based on the contents on the where parameter. If the where parameter contains an equal-sign, then all occurrences of characters in which is deleted from the current value. If the where parameter contains a less-than, then the characters are only deleted when they are first in the string. If the where parameter contains a greater-than, then the characters are only deleted when they are the last in the string. If the where parameter contains any other char, an exception is thrown. If the where parameter or the which parameter is empty, the source is returned unmodified. The which parameter is to be considered as an array of chars to delete where the order does not matter.
StrCheckSum(String [, String] [, Integer]) Calculates a checksum for a string that contains a number. If the source is empty, 0 is returned. Each char in the source and in the weight must be a numeric character 0-9, otherwise an exception is thrown. If the WeightString parameter is shorter then the source, it is padded with '1' up until the length of source. If the WeightString parameter is longer than the source, an exception is thrown.
ConvertStr(String, String, String) Replaces all chars in source found in FromCharacters with the corresponding char in ToCharacters and returns the converted string. If the length of the FromCharacters parameter and the ToChars parameter are different, an exception is thrown. If the parameter FromCharacters or the parameter ToChars is empty, the source is returned unmodified. Each element in source is only converted ONCE a double-replacement cannot happen.
LowerCase(String) Converts all letters in a string to lowercase.
UpperCase(String) Converts all letters in a string to uppercase.
SelectStr(Integer, String) Retrieves a substring from a comma-separated string.
DelStr(String, Integer [, Integer]) Deletes a substring inside a string (text or code).
InsStr(String, String, Integer) Inserts a substring into a string.

The following methods are available on instances of the Text 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.
StartsWith(Text) Determines whether the beginning of this instance matches a 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.
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.
TrimStart([Text]) Removes all leading occurrences of a set of characters specified in an array from the current Text object.
TrimEnd([Text]) Removes all trailing occurrences of a set of characters specified in an array from the current Text object.

See Also

Getting Started with AL
Developing Extensions