Click or drag to resize

AllTrim Function

X#
Remove leading and trailing spaces from a string.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax
 FUNCTION AllTrim(
	Expression AS STRING,
	Flags AS LONG,
	TrimChars PARAMS STRING[]
) AS STRING
Request Example View Source

Parameters

Expression
Type: String
Specifies an expression to remove leading and trailing spaces or 0 bytes from
Flags
Type: Long
Specifies if trimming is case-sensitive when one or more parse characters (cParseChar, cParseChar2, … are included. Trimming is case-sensitive if nFlags is zero or is omitted. Trimming is case-insensitive if nFlags = 1.
TrimChars
Type: String
Specifies one or more character strings that are trimmed from the beginning of cExpression. If cParseChar isn't included, then leading spaces or 0 bytes are removed from Expression.

Return Value

Type: String
A trimmed string, with leading and trailing spaces removed.
Remarks
AllTrim() is related to LTrim() and RTrim(), which remove leading and trailing spaces, respectively.
The inverse of AllTrim(), LTrim(), and RTrim() are the PadC(), PadL(), and PadR() functions, which center, left-justify, and right-justify strings by padding them with fill characters.
Examples
This example creates a string with both leading and trailing spaces, then trims them with AllTrim():
X#
1LOCAL cString AS STRING
2cString := SPACE(10) + "string" + SPACE(10)
3? SLen(cString)                            // 26
4? SLen(ALLTRIM(cString))                    // 6
See Also