ALLTRIM( ) function
Returns a string with leading and trailing spaces removed from the input string.
Syntax
ALLTRIM(string)
Parameters
Name | Type | Description |
---|---|---|
string | character | The value to remove leading and trailing spaces from. |
Output
Character.
Examples
Basic examples
Returns "Vancouver":
ALLTRIM(" Vancouver ")
Returns "New York":
ALLTRIM(" New York ")
Advanced examples
Concatenating character fields
Use ALLTRIM( ) to eliminate spaces when you concatenate character fields, such as first name and last name fields, so that the resulting field does not contain multiple blank spaces between the concatenated values.
DEFINE FIELD Full_Name COMPUTED ALLTRIM(First_Name) + " " + ALLTRIM(Last_Name)
Removing non-breaking spaces
Non-breaking spaces are not removed by the ALLTRIM( ) function.
If you need to remove leading or trailing non-breaking spaces, create a computed field using the following expression:
DEFINE FIELD Description_cleaned COMPUTED ALLTRIM(REPLACE(Description, CHR(160), CHR(32)))
The REPLACE( ) function replaces any non-breaking spaces with regular spaces, and then ALLTRIM( ) removes any leading or trailing regular spaces.
Remarks
How it works
The ALLTRIM( ) function removes the leading and trailing spaces from a string. Spaces inside the string are not removed.
Related functions
Use the LTRIM( ) function if you want to remove only leading spaces from a string, or the TRIM( ) function if you want to remove only trailing spaces.