العودة إلى  مدرسة الكمبيوتر   قسم البرمجة    الصفحة الأولى

#IF ... #ENDIF Preprocessor Directive

Conditionally includes source code at compile-time.

Syntax

#IF nExpression1 | lExpression1
  Commands
[#ELIF nExpression2 | #ELIF lExpression2
  Commands
   ...
#ELIF nExpressionN | #ELIF lExpressionN
  Commands]
[#ELSE
  Commands]
#ENDIF

Arguments

#IF nExpression1 | lExpression1
Commands

nExpression1 specifies the numeric expression that is evaluated.

  • If the expression is nonzero, the commands immediately following #IF are included in the compiled code. The #IF ... #ENDIF structure is exited, and the first program line following #ENDIF is then compiled.

     
  • If the expression is 0, the commands immediately following #IF are not included in the compiled code. Any following #ELIF directives are evaluated.

    lExpression1 specifies the logical expression that is evaluated.

  • If the expression is true (.T.), the commands immediately following #IF are included in the compiled code. The #IF ... #ENDIF structure is exited, and the first program line following #ENDIF is then compiled.

     
  • If the expression is false (.F.), the commands immediately following #IF are not included in the compiled code. Any following #ELIF directives are evaluated.

    Note   Do not specify system variables for nExpression1 or lExpression1. System variables are not evaluated until run time.

#ELIF nExpression2 | #ELIF lExpression2
Commands


...

#ELIF nExpressionN | #ELIF lExpressionN
Commands

If nExpression1 is 0 or lExpression1 is false (.F.), the #ELIF directives are evaluated. The first #ELIF expression nExpression2 or lExpression2, if present, is evaluated. If nExpression2 is nonzero or lExpression2 is true (.T.), the commands following #ELIF are included in the compiled code. The #IF ... #ENDIF structure is exited, and the first program line following #ENDIF is then compiled.

If nExpression2 is 0 or lExpression2 is false (.F.), the commands following #ELIF are not included in the compiled code. The next #ELIF directive is evaluated.

#ELSE Commands

If no #ELIF directives are included, or if those that are included evaluate to 0 or false (.F.), the presence or absence of #ELSE determines whether any additional commands are included in the compiled code:

  • If #ELSE is included, the commands following #ELSE are included in the compiled code.

     
  • If #ELSE is not included, none of the commands between #IF and #ENDIF are included in the compiled code. The #IF ... #ENDIF structure is exited, and compilation continues on the first program line following #ENDIF.

#ENDIF

Indicates the end of the #IF statement.

Remarks

#IF ... #ENDIF can improve the readability of source code, reduce compiled program size, and, in some cases, improve performance.

When the #IF ... #ENDIF structure is compiled, successive logical or numeric expressions within the structure are evaluated. The evaluation results determine which set of Visual FoxPro commands (if any) are included in the compiled code.

 

 طباعة المقال العودة إلى  مدرسة الكمبيوتر   قسم البرمجة    الصفحة الأولى
Syria
سورية
Amrit
عمريت
أرواد
طرطوس
صور من طرطوس
صور من سورية
للسيدات فقط
معجم الكمبيوتر
أدب وفكر
المجلة الطبية
المعلومات العامة
لمحة عن طرطوس
الموضة النسائية
مدرسة الكمبيوتر
 © 2002-2012 LBCInformation Corporation. All rights reserved م حنا عطا لحود.