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. Todos os direitos reservados. TOTVS, Protheus, Microsiga e seus respectivos logotipos são marcas de titularidade da TOTVS S.A. AdvPL é uma linguagem de programação desenvolvida pela TOTVS. O AdvPL Guia é um projeto independente, sem vínculo, representação, patrocínio ou afiliação com a TOTVS S.A., suas franquias ou representantes.