aDestSearched array.
AdvPL GuideAScan( <aDest>, <xExpr>, [nStart], [nCount] ) --> nRetFinds the first position matching a value or search block.
AScan returns the matched position or zero. For multidimensional structures its block receives each first-level element and must return logical. Simple string comparisons depend on SET EXACT; a block using == makes equality explicit. The returned index belongs to the source even when the search range starts elsewhere. (TOTVS, s.d., ref. 1)
AScan( <aDest>, <xExpr>, [nStart], [nCount] ) --> nRetaDestSearched array.
xExprSimple value or logical block.
nStartFirst position; default 1.
nCountCount from the starting position; defaults through the end.
Position starting at 1; zero when not found.
#Include "Protheus.ch"
User Function EdAscan()
Local aItems := {{"A", 10}, {"B", 20}}
Local nPos := AScan(aItems, {|aRow| aRow[1] == "B"})
// Zero is not a valid array index.
If nPos > 0
ConOut(cValToChar(aItems[nPos][2]))
EndIf
Return NilExpected position: 2; output 20. 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.