Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

FieldBlock

FieldBlock( cField ) --> bRet

Creates a block for reading or assigning a field.

FieldBlockAdvPL
01 · OVERVIEW

Overview

A FieldBlock block reads when evaluated without a value and assigns when supplied a value. Not every Eval is harmless reading. A missing field can allow block creation and fail only on evaluation. This GitHub adaptation checks field and record position, evaluates without a write value and keeps EDTRB context during creation and evaluation. It reports value type rather than registration data. 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

FieldBlock( cField ) --> bRet

Parameters

cField
CharacterRequired

Existing field name in the alias.

Return value

Field-access block; definition errors can return Nil.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed383()
    Local bRead
    Local xValue
    If Select("EDTRB") > 0
        If EDTRB->(FieldPos("ED_COD")) > 0 .And. !EDTRB->(Eof())
            bRead := EDTRB->(FieldBlock("ED_COD"))
            // No second argument: do not assign the field.
            xValue := EDTRB->(Eval(bRead))
            ConOut(ValType(xValue))
        EndIf
    EndIf
Return Nil
Expected result

With prepared schema/record, expected type C without assignment. 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. FieldBlock. TDN. Accessed on 2026-10-26.
  2. EURAI. ADVPL/Funcoes/Acesso a Dados/FieldBlock.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