FOUNDATIONPublished
Static Function
Static Function <Nome>()Declares a helper function visible only inside the source file where it is defined.
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.
Syntax
Static Function <Nome>()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 + nValorBExpected result
CalculaTotal() exists only for the current source and keeps the main routine simpler.
- 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.
- 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.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.