Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Eval

Eval( bBloco, [xVariavel] ) --> xRetorno

Executes a block and returns its last expression.

EvalAdvPL
01 · OVERVIEW

Overview

Eval executes the supplied block rather than merely inspecting it. Its return can be any type, depending on the last evaluated expression. Arguments are passed under the call contract. The example uses a pure calculation block and fixed input without macro-compiling external text or accessing tables. Check effects before evaluating interface or database callbacks. (TOTVS, n.d., ref. 1)

02 · SYNTAX

Syntax

Eval( bBloco, [xVariavel] ) --> xRetorno

Parameters

bBloco
Code blockRequired

Block to execute.

xVariavel
AnyOptional

Argument supplied to the block.

Return value

Value of the block’s last expression.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed370()
    Local bDouble := {|nValue| nValue * 2}
    // Local calculation only, without external effects.
    ConOut(cValToChar(Eval(bDouble, 4)))
Return Nil
Expected result

Expected result: 8. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Validate block input and understand dependencies before execution.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

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