Work areas and aliases
GetArea() -> aArea; RestArea(aArea)Preserves position and order when reading open areas.
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.)
Syntax
GetArea() -> aArea; RestArea(aArea)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 NilPrints A and restores the captured context. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- 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.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.