Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Empty

Empty( xExp ) --> lRet

Tests emptiness according to value type.

EmptyAdvPL
01 · OVERVIEW

Overview

Empty means more than Nil: zero and false are also empty. Empty or space-only strings and zero-length arrays return true; arrays with elements are not empty even when their items are. TOTVS distinguishes ASCII 32 spaces from tabs/newlines in Protheus versions. Do not replace missing-parameter checks with Empty when zero is valid. The public example uses strings; the adaptation also exposes numeric behavior. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

Empty( xExp ) --> lRet

Parameters

xExp
AnyRequired

Value to test.

Return value

Logical result under type-specific rules.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed361()
    // Emptiness is not parameter absence.
    ConOut(cValToChar(Empty(0)))
    ConOut(cValToChar(Empty({""})))
Return Nil
Expected result

Expected results: true and false. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • For optional arguments, check type and contract before defaulting.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Empty. TDN. Accessed on 2026-10-26.
  2. EURAI. ADVPL/Funcoes/Validacao/UAEmpty.PRW. universo_do_desenvolvedor_site, commit a5c83e9490302bdb4a0fc5a9d92c2d569a60773c. Exemplo analisado. Accessed on 2026-10-26.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR

Was this content helpful?

👍 Like 0👎 Dislike 0

Sign in to rate this article.

0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha