expressão lógicaCondition that determines whether the corresponding block runs.
AdvPL GuideIF <expressão lógica> ... [ELSEIF <expressão>] ... [ELSE ...] ENDIFExecutes a block of commands according to the result of a logical expression.
IF ... ENDIF controls instruction execution from a condition. When the expression is true (.T.), the block after IF runs. If it is false (.F.), ELSEIF clauses may test alternatives in order and ELSE may provide a default path. After one alternative runs, control continues after ENDIF.
IF <expressão lógica> ... [ELSEIF <expressão>] ... [ELSE ...] ENDIFexpressão lógicaCondition that determines whether the corresponding block runs.
ELSEIFAllows alternative conditions to be evaluated in sequence.
ELSEOptional block executed when no previous condition returns .T.
User Function ExDueDate(dDueDate)
Local cMessage := ""
If Date() > dDueDate
cMessage := "Due date exceeded"
Else
cMessage := "Within the deadline"
EndIf
MsgInfo(cMessage)
ReturnThe comparison determines which block assigns the message shown to the user.
User Function ExFaixa(nTotal)
Local cFaixa := ""
If nTotal > 100000
cFaixa := "Especial"
ElseIf nTotal > 50000
cFaixa := "Alta"
ElseIf nTotal > 10000
cFaixa := "Média"
Else
cFaixa := "Padrão"
EndIf
Return cFaixaThe first true condition sets the tier; remaining alternatives are ignored.
User Function ExAcesso(lAtivo, nNivel)
Local lPermitido := .F.
If lAtivo .And. nNivel >= 3
lPermitido := .T.
EndIf
Return lPermitidoAccess is allowed only when both conditions are true.
© 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.