xParametroParameter already declared in the function.
AdvPL GuideDEFAULT xParametro := xValorProvides a default for an omitted parameter.
DEFAULT is the traditional way to supply a value when a parameter is Nil; zero, false and empty text are not absence. The example applies a default then checks type because DEFAULT does not validate supplied arguments. Current documentation presents FWADVPLDEFAULT for AdvPL parameters and distinguishes TLPP FWDEFAULT/FWNULLDEFAULT. Those forms require updated Protheus.ch, a predeclared parameter and individual use; do not assume old-include availability or use them to create Private variables. (TOTVS, n.d., refs. 1–2)
DEFAULT xParametro := xValorxParametroParameter already declared in the function.
xValorDefault value compatible with the contract.
Conditional assignment command, not a function with its own return.
#Include "Protheus.ch"
User Function Ed346(nValue)
// Supplied zero remains zero; an omitted argument receives 10.
Default nValue := 10
If ValType(nValue) <> "N"
Return Nil
EndIf
Return nValue * 2U_Ed346() returns 20; U_Ed346(0) returns 0; text returns Nil after validation. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
© 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.