#IFNDEF
 
Parameters: NONE
Returns: NONE
 

      #IFDEF and #IFNDEF are similar to the #IF directive. It is also used in conjunction with #ELSE and #ENDIF and evaluated during compile time. It allows you selectively define sections of code that should be compiled, or be ignored.

      The difference is that #IFDEF returns True if a specified variable was previously defined, and #IFNDEF returns True if a specified variable was not defined.


Example
  
  
  Var1 = 12
; Var2 = 0
  
  #IFDEF Var1
  Print "Var1 is defined"
  #ENDIF
  
  #IFNDEF Var2
  Print "Var2 is NOT defined
  #ELSE
     Print "Var2 is defined
  #ENDIF
  
  Sync
  WaitKey
  



#IF/#ELSE/#ENDIF

      Previously with the #IF/#ENDIF we've only been able to selectively compile one section code when the #IF expression is TRUE. However some times you need to selectively choose between two sections of code to compile. With the #ELSE directive, we gain this control.

      Depending upon the #IF expression is TRUE OR FALSE, will determine which section of code is compiled. So logically, when the #IF condition is TRUE, the code between the #IF and #ELSE directives is compiled. But when #If the condition is FALSE, the code after the #ELSE and between the #ELSE-#ENDIF is compiled.


Example

  
  
  Constant Mode = 0
  
  #IF  Mode=0
     Print "This Program Was compiled in Mode Zero"
  #ELSE
     Print "This Program Was compiled in some other Mode"
  #ENDIF
  
  


      This example would display (bellow), since the condition (Mode = 0) is True. Notice how the code between the #ELSE/#ENDIF is not compiled. So only the code between the #IF/#ELSE will exist in the compiled program.

  
  This Program Was compiled in Mode Zero
  




 
Related Info: #ENDIF | #IF :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com