Truncates the right part of a string or buffer. You can specify:
- the number of characters of the truncated string.
- the number of characters to be removed.
sString is string = " Turlututu"
// Truncate the string to 9 characters
Trace(Truncate(sString, 9)) // Displays " Turlutut"
Trace(Truncate(sString, 9, numberOfCharactersToStore)) // Displays " Turlutut"
// Truncate the string to 4 characters
Trace(Truncate(sString, 4, numberOfCharactersToDelete))
// Displays " Turlu"
Syntax
<Result> = Truncate(<Source> , <Number of characters> [, <Truncate method>])
<Result>: Character string
- Truncated string.
- EOT if <Number of characters> is negative. A WLanguage error occurs (non-fatal error). To get more details on the error, use ErrorInfo.
<Source>: Character string or Buffer
Element to use: String or buffer. This element is not modified.
<Number of characters>: Integer
Corresponds to: - the number of characters that must be kept in the <Result> string (if the numberOfCharactersToStore constant is used).
- the number of characters or bytes that must be removed from <Source> (if the numberOfCharactersToDelete constant is used).
<Truncate method>: Optional Boolean constant
Truncate method to use: | |
numberOfCharactersToDelete | <Number of characters> corresponds to the number of characters that must be removed from <Source>. |
numberOfCharactersToStore (Default value) | <Number of characters> corresponds to the number of characters that must be kept in the <Result> string. |
Business / UI classification: Neutral code