STATICRestricts function visibility to the source file where it was declared.
AdvPL Guide[STATIC] FUNCTION <cNome>( [<uParam1>, <uParam2>, ...] )Declares an AdvPL function, with local parameters and mandatory completion through RETURN.
FUNCTION is the command used to declare a function in AdvPL. The function receives a name, may receive parameters and must finish execution with RETURN. When declared as STATIC FUNCTION, it is visible only inside its own source file; when published as USER FUNCTION, it becomes a routine callable externally according to Protheus environment conventions.
[STATIC] FUNCTION <cNome>( [<uParam1>, <uParam2>, ...] )STATICRestricts function visibility to the source file where it was declared.
cNameName of the declared function. It should be stable when used by menus, entry points or external calls.
uParamNParameters received by the function. Each parameter behaves as a local variable in the function scope.
RETURNEnds the function and optionally returns a value to the caller.
#Include "TOTVS.ch"
User Function ExFunction()
Local nResultado := SomaValores(10, 5)
MsgInfo(CValToChar(nResultado), "Resultado")
Return
Static Function SomaValores(nValorA, nValorB)
Return nValorA + nValorBThe User Function is the entry point. The Static Function receives local parameters, calculates the result and returns the value to the caller.
#Include "TOTVS.ch"
User Function ExValida()
Local cCodigo := "A001"
If CodigoValido(cCodigo)
MsgInfo("Código aceito", "Validação")
EndIf
Return
Static Function CodigoValido(cCodigo)
Return !Empty(AllTrim(cCodigo))The helper function returns .T. or .F., making the validation contract explicit.
© 2026 Usina.BR. All rights reserved. TOTVS, Protheus, Microsiga and their respective logos are trademarks of their owners. AdvPL Guide is independent and uses limited, attributed excerpts justified by educational purposes. See the Terms of Use. Terms of Use
Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.