nPosValid ordinal position in the alias.
AdvPL GuideFieldGet( nPos ) --> xRetReads a field value at the current record position.
FieldGet uses an ordinal position rather than a name. Invalid positions can return Nil with a warning; type depends on schema and queries may need TCSetField for dates/logicals. The GitHub source skips three SA1 records and reads field five without checking EOF. The adaptation locates ED_COD using FieldPos and verifies a valid record before reading without hardcoding an ordinal. Only type is shown. EDTRB is an already-open owned test alias; ED_COD, when used, is a length-10 character field in the teaching schema. (TOTVS, n.d., ref. 1)
FieldGet( nPos ) --> xRetnPosValid ordinal position in the alias.
Field content under its type; Nil in documented error cases.
#Include "Protheus.ch"
User Function Ed384()
Local nPosition
Local xValue
If Select("EDTRB") > 0
nPosition := EDTRB->(FieldPos("ED_COD"))
// Field existence alone is not enough: check the cursor.
If nPosition > 0 .And. !EDTRB->(Eof())
xValue := EDTRB->(FieldGet(nPosition))
ConOut(ValType(xValue))
EndIf
EndIf
Return NilExpected type C under the test schema; field content is not exposed. 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.