Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Field

Field( nPos ) --> cRet

Gets a field name by ordinal position.

FieldAdvPL
01 · OVERVIEW

Overview

Field starts at position 1, excludes internal Recno/Deleted fields and behaves like FieldName. Positions beyond field count return empty text; an absent work area can raise a recoverable error. The community example uses a fixed SA1 position. The adaptation checks field availability before inspecting the first field without assuming its name. 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)

02 · SYNTAX

Syntax

Field( nPos ) --> cRet

Parameters

nPos
NumericRequired

Field position starting at 1.

Return value

Field name or empty string in documented cases.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed382()
    If Select("EDTRB") > 0
        // The schema field count may differ from a sample.
        If EDTRB->(FCount()) > 0
            ConOut(EDTRB->(Field(1)))
        EndIf
    EndIf
Return Nil
Expected result

First owned-schema field name rather than its value. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Use only an owned test table with known schema. Qualify the alias, check record position and manage context changes under the caller contract.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Field. TDN. Accessed on 2026-10-26.
  2. EURAI. ADVPL/Funcoes/Acesso a Dados/Field.PRW. universo_do_desenvolvedor_site, commit a5c83e9490302bdb4a0fc5a9d92c2d569a60773c. Exemplo analisado. Accessed on 2026-10-26.
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