Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONPublished

ExistBlock

ExistBlock( <cPontoEntrada> ) --> lExiste

Checks whether an entry point or custom block exists before executing it.

Entry pointsFrameworkCustomizationEssential functions
01 · OVERVIEW

Overview

ExistBlock() checks whether a given customization is available in the environment. In extensible routines, it prevents calling ExecBlock() for a missing entry point and makes the code safer across customer, branch or module variations.

02 · SYNTAX

Syntax

ExistBlock( <cPontoEntrada> ) --> lExiste

Parameters

cPontoEntrada
CaracterRequired

Nome do ponto de entrada, bloco ou identificador de customização a verificar.

Return value

Lógico. Retorna .T. quando o bloco existe e .F. quando não existe.

03 · PRACTICAL EXAMPLE

Executar ponto de entrada apenas se existir

#Include "TOTVS.ch"

User Function ExExistBlock()
    Local lValid := .T.

    If ExistBlock("MA030VLD")
        lValid := ExecBlock("MA030VLD", .F., .F.)
    EndIf

    If lValid
        MsgInfo("Validation authorized.")
    EndIf
Return
Expected result

The entry point is called only when it exists in the environment.

BEST PRACTICES
  • Use antes de ExecBlock() quando a customização for opcional.
  • Documente o ponto de entrada esperado e o contrato de retorno.
  • É comum em fontes que precisam funcionar em vários ambientes sem exigir todas as customizações.
COMMON PITFALLS
  • ExistBlock() só informa existência; a validade dos parâmetros e do retorno continua sendo responsabilidade da rotina.
  • Evite transformar pontos opcionais em dependência invisível sem documentação.

Related content

REFERENCES
  1. RXM Tecnologia. 20 essential AdvPL functions every Protheus developer uses. May 2026.
Status
Published
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