The CSPro compiler operates in one of two modes:
You must declare all variables
not defined in your dictionary; otherwise, the variables will be flagged as errors by the compiler. The advantage of this mode is that you do not have to worry about misspelled names. The default compiler mode is explicit, which means that any variable used in a program must be declared in a numeric or alpha statement.
This allows you to declare a variable "on the fly," i.e., anywhere in your program. For example, simply coding "myvar = 3;
" in any procedure or function automatically declares a numeric variable "myvar." All such declarations are global in scope, meaning you can assign or get the value from any other procedure. User-defined functions
, string variables
, and arrays
must still be declared in PROC GLOBAL
The advantage of this mode is that you can write your code more quickly. The danger in using this mode is that you may misspell the name of a variable or dictionary item. If you do this, the compiler will create a separate variable for the misspelled name. For example, you may code "if mivar = 3 then
" and the compiler will create a new variable "mivar", with initial value 0, and therefore evaluate the condition as false.
You can change the default mode on your computer by checking or unchecking the "Option/Set Explicit" setting. This setting will then remain in effect for all applications. Note that this setting is in effect only on your computer; if you move your application to another computer with a different setting, you may get a different result when you compile.
You can override the computer's default setting mode by using the set statement
in PROC GLOBAL
. In this case your application will always give the same result on any machine.