Usina BRAdvPL Guide
Sign in
← All topics
COMMANDUnder review

LOCAL

LOCAL xVariable [:= xInitial], ...

Declares function-local variables.

LOCALAdvPL
01 · OVERVIEW

Overview

An uninitialized declaration leaves NIL, which should not be used directly in arithmetic. Initialize values and pass data explicitly to avoid Private/Public dependencies. This subset does not redefine block capture or the distinction between declared type and assigned value. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

LOCAL xVariable [:= xInitial], ...

Return value

Declaration command; no function return.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed508()
    Local nQty := 3
    Local nUnit := 10
    Local nTotal := nQty * nUnit
    // Initialize before calculating.
    ConOut(cValToChar(nTotal))
Return Nil
Expected result

Result: 30. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Declare variables at routine start and avoid framework-reserved names.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. Waterloo Ferreira da Silva. AdvPL — O Manual, versão 1.0, p. 36. Referência histórica. Accessed on 2026-10-27.
  2. Waterloo Ferreira da Silva. AdvPL — O Manual, versão 1.0, p. 37. Referência histórica. 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