Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

FCount

FCount() --> nRet

Counts work-area fields rather than records.

FCountAdvPL
01 · OVERVIEW

Overview

FCount inspects active-area structure and returns the field count. It does not count records and does not replace LastRec. The community source selects SA1 first; the adaptation explicitly qualifies the owned table rather than selecting a caller area to inspect metadata. 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

FCount() --> nRet

Return value

Number of fields in the structure.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed379()
    // Inspect metadata without visiting records.
    If Select("EDTRB") > 0
        ConOut(cValToChar(EDTRB->(FCount())))
    EndIf
Return Nil
Expected result

Count according to EDTRB schema; no row count. 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. FCount. TDN. Accessed on 2026-10-26.
  2. EURAI. ADVPL/Funcoes/Acesso a Dados/fCount.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