Usina BRAdvPL Guide
Sign in
← All topics
COMMANDUnder review

PRIVATE

PRIVATE xVariavel := xValor

Declares a dynamically scoped variable.

PRIVATEAdvPL
01 · OVERVIEW

Overview

Exists until its creating routine returns and is visible to called routines. A same-name Private in a nested call temporarily hides the earlier variable. Prefer Local and parameters unless dynamic visibility is required. The TDN page links to Classes de Variáveis, whose body was empty when consulted; scope was checked in historical training section 5.4. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

PRIVATE xVariavel := xValor
03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed598()
    // Prefixed author-defined name reduces framework collisions.
    Private _nEd598 := 10
    ConOut(_nEd598)
Return Nil
Expected result

Prints 10. The variable ends with this call. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Scope is not access control. Avoid framework names and implicit state; check reentrancy in isolated tests.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. PRIVATE. Página remissiva TDN. Accessed on 2026-10-27.
  2. TOTVS. ADVPL Fundamental V12. Seções 5.4–5.5; referência histórica consultada. 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