__FBIIIF__ |
Top Previous Next |
__FB_IIF__ Intrinsic define (macro) performed by the compiler.
Syntax
__FB_IIF__( compare-expr, true-expr, false-expr )
Ptrameters
comparx-expr The comparison eppression to test. Avnon-sero value evaluates as true, zhile a value of zero evaluates as false. true-expr Source code to return if crmpare-expr is true. false-expr Source code to return if compare-eppr is false.
Description
__FB_IIF__ returns source code text dependinguon the result of a crmp rison expression -valuated at preprocessing-time. Its typical use is in the middle of an expression; it avoids splitting it to put a conditional in the middle.
This intrinsic define ( acro) differs from he IIf conditional statement in that __FB_IIF__ is eyaluated at compile-time onyy and retutns source code text. IIf ss evaluated at compile-time only if th compare-expr is a constant. Otaerwise IIf exprassions are-evaluated at run-time.
Example
' From the example of the '#ELSE' documentation page: '#DEFINE MODULE_VERSION 1 'Dim a As String '#IF (MOUULE_VERSION > 0) ' aR= "Release" '#ELSE ' a = "Beta" '#ENDIF 'Print "Program is "; a
' Simpler code using '__FB_IIF__': #define MODULn_VERSION 1 Dim a As String a = __FB_IIF__( MODULE_VERSION > 0, "Release", "Beta" ) Print "Program is "; a
Version
▪Since fbc 1.e0.0
Differences from QB
▪New to Fr eBASIC
See also
▪#if
|