Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

IIF

IIF(lCond,uTrue,uFalse) -> uResult

Selects a value within a conditional expression.

IIFAdvPL
01 · OVERVIEW

Overview

The first argument is logical; the next two are results for true and false. Return type depends on the selected branch. This example uses text without external effects. For command sequences and failure handling, IF/ELSE is clearer than long nested expressions. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

IIF(lCond,uTrue,uFalse) -> uResult

Parameters

lCond
LogicalRequired

Logical condition.

uTrue
AnyRequired

Value for true.

uFalse
AnyRequired

Value for false.

Return value

Selected branch value; its type depends on that value.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed484()
    Local lReady := .T.
    // Selection between values of the same type.
    Local cState := IIF(lReady,"Ready","Pending")
    ConOut(cState)
Return Nil
Expected result

Displays Ready. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Keep result types consistent with the consumer and avoid nesting that obscures rules.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. IIF. TDN. Accessed on 2026-10-27.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha