Report Options - Options Tab - All Variables in Functions Must be Declared¶
This option, turned on by default for new reports, tells the DataFlex Reports Studio to check whether all variables used in functions are declared with a DIM statement.
The behavior of automatically declaring non-declared variables as local variables prior to version 8.2 may seem convenient, but it can lead to unintended consequences. For example, if a report developer makes a typo in the name of a variable, it may go unnoticed, and the behavior of the program may change drastically. Similarly, if a developer assumes that a variable is a global variable but the engine did not execute the routine to create the global variable, it will be declared and handled as a local variable, which can cause unexpected behavior.
This behavior can make debugging more difficult and time-consuming, as developers may have to spend more time searching for the source of the problem. To avoid such issues, it is recommended that developers declare their variables explicitly, either as local or global, depending on their intended use. This not only makes the code easier to understand and maintain but also reduces the risk of introducing bugs caused by unintentionally creating new variables.