Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

ExecBlock

ExecBlock( <cNomeFuncao>, [lPerg], [lMostra], [aParametros] )

Dynamically executes a routine by name, a common resource in triggers and standard launches.

Dynamic executionBlocksTriggersFunctions
01 · OVERVIEW

Overview

ExecBlock appears in introductory material as a way to reference and execute a program by name in situations such as triggers and standard launches. Because it executes a routine from a textual identifier, it requires caution with parameters, function existence and side effects.

02 · SYNTAX

Syntax

ExecBlock( <cNomeFuncao>, [lPerg], [lMostra], [aParametros] )
03 · PRACTICAL EXAMPLE

Conceptual dynamic call

#Include "TOTVS.ch"

User Function ExExecBlock()
    Local cRotina := "U_ProcessaItem"
    Local aParametros := {"001"}

    ExecBlock(cRotina, .F., .F., aParametros)
Return
Expected result

The routine identified by name is called with the informed parameters, according to environment availability and contract.

BEST PRACTICES
  • Use somente quando a chamada dinâmica fizer sentido no desenho da rotina.
  • Documente o nome da função chamada e os parâmetros esperados.
  • Valide em homologação quando o uso estiver ligado a gatilhos ou processos automáticos.
COMMON PITFALLS
  • Function-name errors appear only at runtime.
  • Dynamic calls make dependencies harder to trace.
  • Routines called by triggers should be fast and predictable.

Related content

REFERENCES
  1. Apostila ADVPL Introd. Microsiga Campinas, 2001. Documentação oficial histórica de caráter didático e de suporte. Conteúdo histórico, resumido, revisado e adaptado para guia de referência.
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