Implicit Variable Declarations

In addition to explicit declaration of variables via MAP or DIMX statements, provided you do not use the /M COMPIL switch, you may implicitly declare variables simply by using them. In the absence of the /M switch, when the compiler sees a variable that has not previously been declared, it creates an implicit MAP statement for it, based on the following rules:

•   If the variable name ends in $, it will be auto-mapped as a string according to the default string size specified by a prior STRSIZ statement (which has a default value of 10 bytes).

•   Otherwise it will be auto-mapped as F,6

Note: it is strongly recommended that you do not take advantage of this dubious feature, since it makes it all too easy to introduce bugs into programs via typos and misspellings of variable names. Furthermore, it is recommended that you use COMPIL /M to force all variables to be explicitly declared. If you are working with a large set of code which uses a lot of implicit variable declarations, an easy way to locate and create explicit MAP statements for all of the undeclared variables is to use the COMPIL /L switch, which creates a .LSX listing, at the end of which will appear the auto-mapped variables. You can review the list—perhaps sort it first to help spot similar names possibly referring to the same thing—and then just yank the set of MAP statements into the source code to make those variable declarations explicit, after which you can take advantage of the /M switch.