Xbasic

TRIM Function

Syntax

Output_String as C = TRIM(C character)

Arguments

character

A character string.

Description

Removes trailing blanks from a character string.

Discussion

Removes trailing blanks from a character string. TRIM() is the same as RTRIM(). This function is commonly used to prepare fields before concatenating them with the " + " operator.

Example

FIRSTNAME + LASTNAME -> "Beverly    Brine   "
trim(FIRSTNAME) + LASTNAME -> "BeverlyBrine       "

Assume you have defined a table with FIRSTNAME, INITIAL, and LASTNAME fields. You want to print a report that displays the name in its proper format (e.g., John S. King). You can do this by defining a calculated field, called FULLNAME, with the following expression:

if(isblank(INITIAL), trim(FIRSTNAME) + " " + LASTNAME, trim(FIRSTNAME) + " " + trim(INITIAL) + ". " + LASTNAME)

See Also