#ELSE
#ELSE
 
Parameters: NONE
Returns: NONE
 

      #ELSE is used in combination with the conditional #IF / #ENDIF directives. #ELSE allows the #IF directive to choose between two paths the compiler could take.

      #If performs a comparison of a constant expression at compile time, if the expression resolves to be true, the code following the #IF statement and between the #ELSE statements will be compiled. If not, then the code between the #ELSE-#ENDIF will be ignored.


      For more information on the logic behind #IF / #ELSE / #ENDIF statements, please refer to the #IF page.



FACTS:


      * #IF/#ELSE/ #ENDIF are directive all evaluated at compile time.




Mini Tutorial:


This simple examples shows how to use th #IF/#ELSE/#ENDIF directives to conditional select a section of code to compile.

  
  
  Constant MyFlag = 100
  
; Compare the MYFLAG constant during compilation with 50. If
; the constant is greater than 50, then the compiler will include
; this code section.
  
; if not.. it will ignore those lines completely and compile the code
; between the #ELSE and #ENDIF.
  
  #IF  MyFlag > 50
     
     Print "Yes My Flag was bigger than 50"
     Print "Yippie"
     
  #ELSE
     Print "This Code will not be compiled"
     Print "as the #IF expresion above is TRUE"
     
  #ENDIF
  
  
  
; Display the Screen and wait for the user to press a key
  Sync
  WaitKey
  




This example would output.

  
  yes My Flag was bigger than 50
  Yippie
  



 
Related Info: #Abort | #ENDIF | #IF | #IFDEF | #IFNDEF | #Warn | Comparisons :
 


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