Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

AllTrim

AllTrim( <cText> ) --> cRet

Removes spaces from both ends of a string.

AllTrimAdvPL
01 · OVERVIEW

Overview

AllTrim returns a new string without leading or trailing spaces while retaining internal spaces. The official reference also documents an empty result for non-character input; this is not number-to-text conversion. Compare LTrim and RTrim for one-sided trimming. The original variable changes only if the result is assigned to it. (Ref. 1)

02 · SYNTAX

Syntax

AllTrim( <cText> ) --> cRet

Parameters

cText
AnyRequired

Text to trim; note the documented behavior for other types.

Return value

Character: text without edge spaces; non-character input yields an empty string according to TDN.

03 · PRACTICAL EXAMPLE

Commented example

#Include "TOTVS.ch"

User Function EdTrim()
    Local cText := "  Ana  Silva  "
    // Brackets expose the boundaries of the result.
    ConOut("[" + AllTrim(cText) + "]")
    // AllTrim does not convert the number to text.
    ConOut("[" + AllTrim(42) + "]")
Return Nil
Expected result

Expected results: [Ana Silva] and []. The internal double space remains. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Check the type before normalization when an empty result could hide invalid input. Do not assume every Unicode whitespace character is removed.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. AllTrim. Frameworksp/TDN. Accessed on 2026-10-24.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha