Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

BuildExpr

BuildExpr( <cAlias>, [oWnd], <cFilter>, [lTopFilter], [bOk], [oDlg], [aUsado], [cDesc], [nRow], [nCol], [aCampo], [lVisibleTopFilter], [lExpBtn], [cTopFilter] ) --> cRet

Opens a dictionary-driven visual filter-expression builder.

BuildExprAdvPL
01 · OVERVIEW

Overview

BuildExpr uses SX2/SX3 to offer fields and construct a filter expression. The historical page lists 14 positions; cAlias and cFilter are required by the described contract, so the example explicitly supplies an empty string as the third argument while keeping Nil for the window object. Returned text is not an executed query. aUsado/aCampo can restrict fields; do not freely convert received text into code or assume the builder authorizes data access. Requires an interactive session and a registered, open alias. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

BuildExpr( <cAlias>, [oWnd], <cFilter>, [lTopFilter], [bOk], [oDlg], [aUsado], [cDesc], [nRow], [nCol], [aCampo], [lVisibleTopFilter], [lExpBtn], [cTopFilter] ) --> cRet

Parameters

cAlias
CharacterRequired

SX2/SX3 alias.

oWnd
ObjectOptional

Reference window.

cFilter
CharacterRequired

Initial expression, possibly empty.

lTopFilter
LogicalOptional

Allows TOP expression; default false.

bOk
Code blockOptional

Validation, dependent on oDlg.

oDlg
ObjectOptional

Related processing dialog.

aUsado
ArrayOptional

Used/restricted fields under the page contract.

cDesc
CharacterOptional

Expression description.

nRow
NumericOptional

Position row.

nCol
NumericOptional

Position column.

aCampo
ArrayOptional

Field configuration.

lVisibleTopFilter
LogicalOptional

TOP filter visibility.

lExpBtn
LogicalOptional

Expression-button control.

cTopFilter
CharacterOptional

Initial TOP expression.

Return value

Character filter expression; the example only checks its length when type is C.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function EdBuildex()
    Local cFilter := ""
    // SA1 must be open in an interactive test session.
    If Select("SA1") > 0
        cFilter := BuildExpr("SA1", Nil, cFilter, .F.)
        If ValType(cFilter) == "C"
            ConOut(cValToChar(Len(cFilter)))
        EndIf
    EndIf
Return Nil
Expected result

Length depends on interaction; no filter application, query execution or record write. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Check all 14 arguments against the installed release reference. Preserve caller context and validate fields and expression before later application.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. BuildExpr. TDN. 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