Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

PadL

PadL(xExp,nLen,[cFill]) -> cRet

Pads a string on the left.

PadLAdvPL
01 · OVERVIEW

Overview

Final length is nLen. xExp is converted to string; omitted cFill uses space, otherwise only its first character is used. Inputs longer than nLen are truncated; nonpositive nLen yields empty text. The community sample compares C/L/R; this adaptation uses visible fill characters. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

PadL(xExp,nLen,[cFill]) -> cRet

Parameters

xExp
AnyRequired

Value converted to text.

nLen
NumericRequired

Final length.

cFill
CharacterOptional

Fill character; defaults to space.

Return value

String of the specified length, or empty for nonpositive nLen.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed566()
    // Visible padding, no data changes.
    ConOut(PadL("AB",6,"-"))
    ConOut(cValToChar(Len(PadL("AB",6,"-"))))
Return Nil
Expected result

Result: ----AB; length 6. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Check length before padding identifiers: truncation can lose information. Define encoding policy; formatting does not validate a business key or field.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. PadL. TDN. Accessed on 2026-10-27.
  2. Atilio. Exemplo 379; commit 7d275a7. Accessed on 2026-10-27.
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