Difference between revisions of "OPTION EXPLICIT"

From QB64 Wiki
Jump to navigation Jump to search
 
Line 29: Line 29:
  
 
''QB64 IDE Status will show:''
 
''QB64 IDE Status will show:''
'''Variable 'myVariabe' (SINGLE) not defined on line 7'''
+
'''Variable 'myVariabe' (SINGLE) not defined on line 4'''
  
  

Latest revision as of 17:00, 29 October 2020

OPTION _EXPLICIT instructs the compiler to require variable declaration with DIM, REDIM or an equivalent statement.


Syntax

OPTION _EXPLICIT


Description

  • With OPTION _EXPLICIT you can avoid typos by having QB64 immediately warn in the Status area of new variables used without previous declaration.
  • Enable OPTION _EXPLICIT temporarily even if a program source file doesn't contain the directive by specifying the -e switch when compiling via command line (qb64 -c file.bas -e).


Errors


Examples

Example: Avoiding simple typos with OPTION _EXPLICIT results shown in the QB64 IDE Status area.

OPTION _EXPLICIT DIM myVariable AS INTEGER myVariable = 5 PRINT myVariabe

QB64 IDE Status will show: Variable 'myVariabe' (SINGLE) not defined on line 4


See also



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page