Removes leading white space, or other specified characters, from a CHARACTER or LONGCHAR expression. The data type of the returned value matches the data type of the expression passed to the function.
The following example shows the effect of the TRIM, LEFT-TRIM, and RIGHT-TRIM functions on a string value:
r-ltrim.p
DEFINE VARIABLE ix AS INTEGER NO-UNDO.
DEFINE VARIABLE txt AS CHARACTER NO-UNDO FORMAT "X(26)"
INITIAL "***** This is a test *****".
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 FRAME butt-frame
txt ix 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"
ix 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" @ ix
LEFT-TRIM(txt,"* ") WHEN SELF:LABEL = "Left Trim" @ txt
LENGTH(LEFT-TRIM(txt,"* ")) WHEN SELF:LABEL = "Left Trim" @ ix
RIGHT-TRIM(txt, "* ") WHEN SELF:LABEL = "Right Trim" @ txt
LENGTH(RIGHT-TRIM(txt, "* ")) WHEN SELF:LABEL = "Right Trim" @ ix
WITH FRAME trimed-frame.
END.
ENABLE b_left b_right b_trim b_quit WITH FRAME butt-frame.
ix = LENGTH(txt).
DISPLAY txt ix WITH FRAME butt-frame.
WAIT-FOR CHOOSE OF b_quit IN FRAME butt-frame.
|