Usina BRAdvPL Guide
Sign in
← All topics
PRACTICAL GUIDEUnder review

Work areas and aliases

GetArea() -> aArea; RestArea(aArea)

Preserves position and order when reading open areas.

Work areas and aliasesAdvPL
01 · OVERVIEW

Overview

GetArea captures the current alias, order and record; RestArea restores that context. It is not data, filter or transaction rollback. When working in another area, save its context through alias execution too. An alias identifies an open work area in this execution, not the physical table name. Closing an area before restoration invalidates the assumption that it still exists. (Sources: refs. 1–2.)

02 · SYNTAX

Syntax

GetArea() -> aArea; RestArea(aArea)
03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed520()
    Local aArea := GetArea()
    // Does not change data or close the saved alias.
    ConOut(ValType(aArea))
    RestArea(aArea)
Return Nil
Expected result

Prints A and restores the captured context. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Restore on error paths too. Close only aliases opened by the routine and keep resource ownership explicit.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. GetArea. TDN. Accessed on 2026-10-27.
  2. TOTVS. RestArea. TDN. 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