#Warn
#Warn "StringConstant"
 
Parameters:

    "StringConstant" = The Message you want to display to the user in the Warnings pop up dialog
Returns: NONE
 

      #Warn is a compile time directive that will halt the compiler and present the user with a message and a YES/NO choice. If the user selects YES the compiler continues as normal, if they select NO then compilation is stopped.

      Much like the #Abort directive, #WARN is mainly used with #IF/#ENDIF directives. Since #IF directives are calculated at compile time, this allows your source code to evaluate constant expressions and conditions as it's being compiled. So you can make compiler make choices about which parts of the code will be included (compiled) and what parts will be skipped over.

      A common use for #WARN may occur when you've written a program in the current version of PlayBASIC, but your unsure if this program will work correctly in future versions perhaps. So as a precaution for future users of your code, it's good idea to notifty the user that this code may not work in this version of PlayBASIC say. While you could simply put this information in your projects documentation, the reality is, most people don't read the Doc's .. :)





FACTS:


      * #Warn is a COMPILE time directive. If the compiler sees the #Warn directive in your source code, it will pop a YES/NO message and will either continue or stop compiling.



Mini Tutorial:


      This example performs a compile time check using the #IF directive against
the PlayBasic version constant. If the Constant (the version number) is greater than 200 (version 2.00),(which it is) this will force the a YES/NO via the #WARN directive. Depending upon what option the user selects will change the outcome. If you choose #yesthe user


  
  
; Use the Compile Time #IF directive to
; Check The build number (version) of the
; PlayBASIC compiler.
  
  #IF playbasicversion<200
     
   ; If the PlayBasicVersion constant is less than 200 (which it will be)
   ; Then  the #if directive is true and then compiler is allowed to compile
   ; the code between the #IF / # ENDIF directives
     
   ;  When the compiler sees #WARN directive here it will display a pop up
   ; message and give you a YES/NO option.
     
     #Warn "This code was made with PB2.00, Compile anwyay?"
  #ENDIF
  
  
; To Get here, the code is either being compiled in a version of PlayBASIC
; that is odler then version 2.00 (200), or the users selected YES to in the
; previous #WARN pop up.
  
  Print "You selected YES... Thanks for compiling me !"
  
  Sync
  WaitKey
  
  




      IF the compile time directive contidtion are met, then this code will be compiled and out the following to the screen.

  
  You selected yes... Thanks For compiling me !
  

 
Related Info: #Abort | #ELSE | #ENDIF | #IF :
 


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