Progress
Language Reference


LEFT-TRIM Function

Interfaces
OS
SpeedScript
All
All
Yes

Removes leading white space, or other specified characters, from a character string.

SYNTAX

LEFT-TRIM ( string [ , trim-chars ] ) 

string

A character expression. The string can be defined as a constant, field name, variable name, or expression. If string is a case-sensitive variable, Progress performs a case-sensitive trim.

trim-chars

A character expression that specifies the characters to be trimmed from string. If you do not specify trim-chars, the LEFT-TRIM function removes spaces, tabs, line feeds, and carriage returns.

EXAMPLE

The following example shows the effect of the TRIM, LEFT-TRIM, and RIGHT-TRIM functions on a string value.

r-ltrim.p
DEFINE BUTTON b_left LABEL "Left Trim".
DEFINE BUTTON b_right LABEL "Right Trim".
DEFINE BUTTON b_trim  LABEL "Trim". 
DEFINE BUTTON b_quit  LABEL "Quit" AUTO-ENDKEY. 
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE txt AS CHARACTER FORMAT "X(26)" INIT
  "***** This is a test *****".
  
DEFINE FRAME butt-frame
  txt i LABEL "String Length" SKIP(2)
  b_left b_right b_trim b_quit
WITH CENTERED TITLE "Original Text String".
 
DEFINE FRAME trimed-frame
  txt LABEL "Trimed Text"
  i   LABEL "Length"
WITH CENTERED.

ON CHOOSE OF b_trim, b_right, b_left IN FRAME butt-frame 
DO:
  FRAME trimed-frame:TITLE  = "Data After " + SELF:LABEL.
  DISPLAY TRIM(txt, "* ") WHEN SELF:LABEL = "Trim" @  txt
    LENGTH(TRIM(txt, "* ")) WHEN SELF:LABEL = "Trim" @ i
    LEFT-TRIM(txt,"* ") WHEN SELF:LABEL = "Left Trim"  @ txt
    LENGTH(LEFT-TRIM(txt,"* ")) WHEN SELF:LABEL = "Left Trim" @ i
    RIGHT-TRIM(txt, "* ") WHEN SELF:LABEL = "Right Trim" @ txt
    LENGTH(RIGHT-TRIM(txt, "* ")) WHEN SELF:LABEL = "Right Trim"  @ i
  WITH FRAME trimed-frame.
END.
       
ENABLE b_left b_right b_trim b_quit WITH FRAME butt-frame.

i = LENGTH(txt).
DISPLAY txt i WITH FRAME butt-frame.

WAIT-FOR CHOOSE OF b_quit IN FRAME butt-frame. 

NOTES

SEE ALSO

RIGHT-TRIM Function, TRIM Function


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095