Simulating FORTRAN 90's IMPLICIT NONE (or Option Explicit in Visual Basic) in QBASIC
March 21 2008 at 12:51 PM
qbguy (no login)
The IMPLICIT NONE statement disables implicit variables, forcing you to declare all your variables like in C. However, this was not available in FORTRAN 77 -- only in FORTRAN 90. The way to get around it is to declare everything implicitly as something really stupid:
IMPLICIT COMPLEX*16 A-Z
It is unlikely you will want a double precision complex number, so you will get an error on an undeclared variable. Another statement that works is
IMPLICIT LOGICAL A-Z
This would declare everything as a boolean, which you probably don't want. You can do even less with a Boolean than with a complex number, virtually guaranteeing that an undeclared variable will cause an error.
(I saw this in some old code as a result on Google when searching for an algorithm)
In QBASIC, the equivalent would be:
This will declare everything as a string, which you probably don't want. Therefore, the compiler will give an error on an undeclared variable.