Tuto WINDEV 25

Part 2: The WLanguage basics 47 A variable declared at project level has the greatest visibility in the program. The variable is visible anywhere, in all program processes. However, you should not declare too many variables with this scope: indeed, the memory occupied by the variable is always reserved even if the variable is not used. Using a large number of global variables is not recommended in the program architecture. To pass variables to a process, we recommend that you use parameters (see "Parameters and result of procedure" for more details). A variable declared at Set of Procedures level and a variable declared at project level have the same visibility. The advantage of declaring a variable at the level of a Set is to group (or classify) the variables by theme (set) in order to make the project initialization process more readable. A variable declared at Window, Mobile Window, Page or Report level limits the scope of the variable to all the processes of the element (Window, Mobile Window, Page or Report) and its controls. This makes it possible to encapsulate and limit the uses. Local scope Local means that the variable has a limited visibility in the code. The variable is visible in the process where it was declared. This makes it possible to restrict the use of variable to the process. Summary scope diagram Each level accesses the variables of higher levels. Project UI (Windows, Pages, Mobile windows, Reports) Processes Global variables Global procedures Local variables Global variables Local procedures A variable is global when it is declared: • in the "Initializing" event of the project (or in the "Declaration" event of the set of procedures). The variable is global to the project. • in the "Global declarations" event of the window, page or report. The variable is global to the element (window, page or report) where it was declared. In all other cases, a variable is local to the process or event where it is declared.

RkJQdWJsaXNoZXIy NDQ0OA==