Usina BRAdvPL Guide
Sign in
← All topics
FOUNDATIONPublished

Static Function

Static Function <Nome>()

Declares a helper function visible only inside the source file where it is defined.

FunctionsScopeCode organizationFoundations
01 · OVERVIEW

Overview

Static Function is used to split a routine into smaller parts without exposing every function to external calls. It helps organize internal rules, reduce coupling and keep the main User Function shorter and more readable.

02 · SYNTAX

Syntax

Static Function <Nome>()
03 · PRACTICAL EXAMPLE

Separating internal logic

#Include "TOTVS.ch"

User Function ExStatic()
    Local nTotal := CalculaTotal(10, 15)

    MsgInfo(CValToChar(nTotal), "Total")
Return

Static Function CalculaTotal(nValorA, nValorB)
Return nValorA + nValorB
Expected result

CalculaTotal() exists only for the current source and keeps the main routine simpler.

BEST PRACTICES
  • Use Static Function para regras auxiliares específicas daquele fonte.
  • Prefira nomes que indiquem claramente a responsabilidade da função.
  • Evite depender de variáveis Private; passe parâmetros quando possível.
COMMON PITFALLS
  • A Static Function should not be used as an external call point.
  • If the rule must be reused by many sources, consider a controlled User Function, class or shared library.

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
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