ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / WLanguage procedures
  • Definition
  • Global procedure
  • Global procedures and sets of procedures
  • Creating a global procedure
  • Creation from the code editor
  • Creation from the "Project explorer" pane
  • Displaying the list of global procedures
  • Deleting a global procedure
  • Deletion from the code editor
  • Deletion from the "Project explorer" pane
  • Test of a global procedure
  • From the code editor
  • From the "Project explorer" pane
  • Public or private global procedure
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Definition
Two types of procedures are available:
  • Global procedure: can be used in all the project processes. This global procedure is stored in the project.
  • Local procedure: can be used in all processes that depend on the object (window, page, report or control) in which this procedure was declared. This local procedure is stored in the object.
Important: You must not declare two procedures with the same name (especially a global procedure and a local procedure).
Reminder:
  • In WLanguage, there is no distinction between the procedures and the functions. The syntaxes for declaring and using procedures also apply to functions.
  • You have the ability to create overloaded procedures. For more details, see Prototype overload.
Global procedure
WINDEVUniversal Windows 10 AppJava

Global procedures and sets of procedures

The global procedures are stored in sets of procedures, associated with the project. Each set of procedures is a ".WDG" file.
Each project contains at least one set of procedures. This set is created by default when creating the project.
The global procedures in a set of procedures can be called from all the events/processes:
  • of the project,
  • of the window or page (events of the window / page, of its controls and processes of the associated local procedures),
  • of the report (events of the report, its controls and processes of the associated local procedures).
Tip: If a procedure is used by a single window or page, this procedure should be described as local to the window or to the page. In this case, the window/page is "independent".
Creating a global procedure

Creation from the code editor

To create a global procedure from the code editor:
  • Method 1:
    • Open the code editor (press F2 while on an element in the window or page).
    • On the "Code" tab, in the "Procedures" group, expand "New" and select "New global procedure" (Shift + F4).
    • In the window that appears:
      • Specify the name of the procedure to create.
      • The option "Generate a header comment" is used to automatically generate the comment for the procedure prototype.
        For more details, see Automatic documentation of procedures.
      • Specify the scope of the procedure. The created procedure is public by default. For more details, see Public or private global procedure.
  • Method 2:
    • Open the code editor (press F2 while on an element in the window or page).
    • Select "New .. New empty global procedure" in the context menu.
    • In the window that appears:
      • Specify the name of the procedure to create.
      • The option "Generate a header comment" is used to automatically generate the comment for the procedure prototype.
        For more details, see Automatic documentation of procedures.
      • Specify the scope of the procedure. The created procedure is public by default. For more details, see Public or private global procedure.
  • Method 3:
    • Open the code editor (press F2 while on an element in the window or page).
    • Position at the end of the procedure code.
    • Type the prototype of procedure to create.
    • Validate. The procedure is automatically created.
To transform a code section already typed in a global procedure into a global procedure:
  1. Select the corresponding code.
  2. Select "New .. Create a global procedure containing the selected code" in the context menu.
  3. Specify:
  4. The procedure is created, the corresponding code is replaced with the call to the procedure with the necessary parameters.

Creation from the "Project explorer" pane

To create a global procedure from the "Project explorer" pane:
  1. Select the "Procedures" folder.
  2. Select the desired set of procedures.
  3. Open the context menu of the set of procedures and select "New global procedure".
  4. In the window that appears:
    • Specify the name of the new global procedure.
    • The option "Generate a header comment" is used to automatically generate the comment for the procedure prototype.
      For more details, see Automatic documentation of procedures.
    • Specify the scope of the procedure. The created procedure is public by default. For more details, see Public or private global procedure.
  5. Validate.

Displaying the list of global procedures

To display the list of global procedures, press Ctrl + F8 in the code editor.
The global procedures are displayed in the "Project explorer" pane if this pane is displayed.
Deleting a global procedure

Deletion from the code editor

To delete a global procedure from the code editor:
  1. Click the bar of the procedure in the code editor.
  2. Select "Delete" in the context menu.

Deletion from the "Project explorer" pane

To delete a global procedure from the "Project explorer" pane:
  1. Select the "Procedures" folder.
  2. Select the desired set of procedures.
  3. Open the context menu of the set of procedures and select "Delete".
Test of a global procedure

From the code editor

To test a global procedure:
  1. Display the global procedure in the code editor.
  2. Click "GO" in the quick access buttons.
  3. The description window of the procedure test is displayed. This window is used to:
    • Enter the different parameters of the procedure.
    • Run the procedure test ("Run the procedure test").
    • Check the return value.

From the "Project explorer" pane

To test a global procedure:
  1. Select the "Procedures" folder in the "Project explorer" pane.
  2. Select the name of the global procedure whose test must be run.
  3. Select "Run the procedure test" in the context menu.
  4. The description window of the procedure test is displayed. This window is used to:
    • Enter the different parameters of the procedure.
    • Run the procedure test ("Run the procedure test").
    • Check the return value.
Public or private global procedure
A global procedure is public by default: it is accessible from anywhere in the code.
In some cases, it may be useful to restrict the access to a global procedure by making it "Private". In this case, the global procedure cab only be accessed by another global procedure in the set of procedures.
When creating a global procedure, you have the ability to specify whether the procedure is public or private.
To modify the access mode to a global procedure:
  1. Select the global procedure in the "Project explorer" pane.
  2. In the context menu of the procedure, select the new access mode::
    • public.
    • private.
The color of the procedure bar changes according to its access mode:
  • red beginning of bar: private procedure.
  • standard beginning of bar: public procedure.
Remark: External component and private global procedures:
The use of private or public global procedures has an impact in the external components. Indeed, only the procedures explicitly declared as private (with the PRIVATE keyword used in their prototype) found in an external component cannot be directly used by the project that includes this component.
Minimum version required
  • Version 12
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/06/2024

Send a report | Local help