Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Len

Len( <xValor> )

Returns the length of a string or the number of elements in an array.

StringsArraysSize
01 · OVERVIEW

Overview

Returns the length of a string or the number of elements in an array. This page was created from the historical training material and structured for quick reference, with practical notes and cautious use in current Protheus environments.

02 · SYNTAX

Syntax

Len( <xValor> )

Parameters

xValor
Character ou ArrayRequired

Parameter used by the function. Check the Portuguese source page for the detailed original wording while this entry remains under review.

03 · PRACTICAL EXAMPLE

Text and array size

User Function ExLen()
    Local cName := "Customer"
    Local aItems := {"A", "B", "C"}

    MsgInfo("Text: " + CValToChar(Len(cName)))
    MsgInfo("Items: " + CValToChar(Len(aItems)))
Return
Expected result

Len(cName) returns the text length and Len(aItems) returns the number of array elements.

BEST PRACTICES
  • Use Len(aArray) ao percorrer arrays.
  • Para strings de campos fixos, combine com AllTrim() quando quiser ignorar espaços laterais.
COMMON PITFALLS
  • This entry is under review because it was structured from historical training material.
  • Confirm behavior in the Protheus/AppServer release used in your environment.

Related content

REFERENCES
  1. Programação em ADVPL Completo. Training material recorded in the official documentation, section 4.5.4, p. 45-50. Summarized, reviewed and examples adapted.
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