Tip avoid using global variables
This means that you must no more use the Global keyword when declaring variables. We know that they were frequently used in V6 version. But we have obvious reasons to forget them:
In service mode, the same process can execute in sequence the same code in two different contexts. By context we mean: user code and folder. Thus, the global variable used to manage contextual parameter values will no more be usable.
In service mode, we might use the same code in different context recursively. Global variables aren't compatible with such types of code.
In V6 version, 90% of the connection time are spent by the procedures that fill the global variables. For a given user, depending on the operation called in the session, less than 20% of the global variables value are really used. We can avoid wasting this time...
The context can be directly accessed via a context instance. This means that we can even have two contexts and manage them in an effective way!
An example of this is the GUSRACS
variable. In version 6, this global variable had a value equal to 2 when the current user has access to all the activity codes, and a value equal to 1 if this wasn't the case. Now in version 7, the corresponding context variable is ALLACS
.
If [V]GUSRACS=2Gosub ACTION_ALLOWEDEndif
would have to be replaced in version 7 by: If this.ALLACS=[V]CST_AYES : # Use GACTX.ALLACS only if a current instance does not existGosub ACTION_ALLOWEDEndif
But they are managed by the supervisor and can be used in some cases. Two examples are given:
this
is not available (that is you are neither in a Method nor in a Rule), there is a global default context available (GACTX).In conclusion: use global variables only if you have no other solution.