Microsoft KB Archive/88885

= INFO: Using the IIF Function in FoxBASE+ or FoxPro =

Article ID: 88885

Article Last Modified on 2/10/2005

-

APPLIES TO


 * Fox Software FoxBASE+ 1.21 for MS-DOS
 * Microsoft FoxBASE+ 2.5 for MS-DOS
 * Microsoft FoxPro 2.0
 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q88885



SUMMARY
The IIF (Immediate If) function returns one of two expressions, depending on the value of a logical expression. When IIF evaluates a logical expression, if the logical expression evaluates to a logical true value (.T.), IIF returns the value of the first expression. If the logical expression evaluates to a logical false value (.F.), IIF returns the value of the second expression.



MORE INFORMATION
The IIF function can be used in place of the IF ... ENDIF structure for simple conditional expressions. This function is especially useful in CREATE REPORT or CREATE LABEL commands to conditionally specify field contents. In a FoxBASE+ or FoxPro report or label, the IIF function is the only conditional statement allowed. The IIF function also executes considerably faster than the equivalent IF ... ENDIF statements.

Examples
  STORE 10 TO Num Char = IIF(Num > 9, STR(Num, 2), STR(Num, 1)) ? Char
 * This code returns 10.

  Store 9 to Num Char = IIF(Num>9, STR(Num, 2), STR(Num, 1)) ? Char
 * This code returns 9.

Additional query words: VFoxWin FoxWin FoxDos 1.00 2.50 2.50a 2.50b 2.60 2.60a 1.x 2.x

Keywords: kbinfo KB88885

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.