Tuto WEBDEV 25
Part 13: The WLanguage basics 431 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 " Procedure parameters", page 460) 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 Set level is to group (or classify) the variables by theme in order to make the "Initializing" project event more readable. A variable declared at Window, Mobile Window, Page or Report level limits the variable scope to all the events 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 initialization code of project (or in the declaration code of set of procedures). The variable is global to the project. • In the declaration code of global variables of 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 where it is declared.
Made with FlippingBook
RkJQdWJsaXNoZXIy NDQ0OA==