xAreaOpen alias or valid area number.
AdvPL GuideDBSelectArea(xArea)Selects an open work area by alias or valid number.
DBSelectArea changes the active work area; unqualified operations then use that area. It neither opens a table nor locates a key. TDN gives conflicting guidance for invalid arguments: it describes errors for numbers at or below zero and deactivation in other cases. This revision removes advice to use zero to find a free area, which this source does not support. The sample only selects an already open alias and restores original context. (Sources: refs. 1–3.)
DBSelectArea(xArea)xAreaOpen alias or valid area number.
The consulted entry does not specify a return contract; the sample does not use it.
#Include "Protheus.ch"
User Function Ed746()
Local aOriginal := FWGetArea()
// Check the alias is open before making it active.
If Select("SB1") > 0
DBSelectArea("SB1")
ConOut(Alias())
EndIf
// This sample owns no aliases: do not close tables.
FWRestArea(aOriginal)
Return NilWith SB1 open, displays SB1 and restores the original area; otherwise does not select SB1. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
© 2026 Usina.BR. All rights reserved. TOTVS, Protheus, Microsiga and their respective logos are trademarks of their owners. AdvPL Guide is independent and uses limited, attributed excerpts justified by educational purposes. See the Terms of Use. Terms of Use
Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.