PBExplicitState
 
Parameters: NONE
Returns: NONE
 

      The PBExplicitState constant contains the current state of the compilers Explicit mode, while it's compling your program. This allows you to write directive code that can ensure parts of your program are built with/or without the compiler forcing variable declaration.


Explicit Modes
      0 = Compiler will allow dynamic variable creation/usage.
      1 = Compiler requires all variables to be previously declared.



Mini Tutorial:


      The following example shows how you can ensure that a section of code will be compiled with a specified Explicit declaration mode enabled/disabled, regardless of the current Explicit mode.

      You can use this for your own code/function libraries. It's a good coding practice when writing libraries of code that are to be used by others, to make sure your library doesn't affect the users personal settings. Thus, by using the PBExplicitState constant you could make the compiler remember the Explicit state and restore at the bottom of your code library. This will ensure the users personal Explicit mode preference/state is preserved. So your library won't activate/disable a mode the user may not be familiar with.


  
; displays the state of PB's Explicit (force declaration) mode
  Print pbexplicitstate
  
; remember the current explicit state
  Constant PreviousExplicitState=pbexplicitstate
; force explicit variable declaration mode on
  Explicit on
  
  
  
; displays the state of PB's Explicit (force declaration) mode
  Print pbexplicitstate
  
  
  
; Restore the Previous Explcit State if needed
  Explicit PreviousExplicitState
  
  
  
; displays the state of PB's Explicit (force declaration) mode
  Print pbexplicitstate
  
  Sync
  WaitKey
  



This example would output

  
  0
  1
  0
  
  



 
Related Info: PBCompileMode | PBDebug | PBDebugMode | PBTraceState | PlayBasicVersion :
 


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