ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage syntax / WLanguage procedures
  • Definition
  • Global procedure
  • Global procedures and sets of procedures
  • Global server and browser 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
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Definition
Two types of procedures are available:
  • Global procedure: can be used in all 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: Do not declare two procedures with the same name (in particular, 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
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystJava

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.
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 only one window or page, it is advisable to describe the procedure as local to the window or page. In this case, the window/page is "independent".
WEBDEV - Server codeWEBDEV - Browser code

Global server and browser procedures

In a dynamic WEBDEV site, two types of procedure collections can exist:
  • server procedure collections (".WDG" file).
  • collections of browser procedures (".WWN" file)
Remarque: A collection of global Browser procedures is converted into a collection of Javascript procedures.. This set of JavaScript procedures is saved in the "<Project name>_WEB" directory and it is named "<Project name>.JS". This set of procedures contains a declaration code and an ending code used to declare the variables global to the set of procedures.
Limit: Global server procedures cannot call global browser procedures, and vice versa.
Creating a global procedure

Creation from the code editor

To create a global procedure from the code editor:
  • Method 1:
    1. Open the code editor (press F2 while on an element in the window or page).
    2. On the "Code" tab, in the "Procedures" group, expand "New" and select "New global procedure" (Shift + F4).
    3. Enter the name of the collection of procedures containing the global procedure and validate..
      Note: If the project already contains a procedure collection, it is possible to select the existing procedure collection..
    4. In the window that appears:
      • Enter the name of the global procedure to be created.
      • 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.
      • Indicate the scope of the procedure (visibility). The created procedure is public by default. For more details, see Public or private global procedure.
      • Indicate the role of the procedure: Undefined, Business, UI. By default, procedures have an "Undefined" role.
    5. Validate. The code editor displays the code of the procedure just created.
    Note: You can also use the "New . New empty global procedure" from a line of code's context menu.
  • Method 2:
    1. Open the code editor (press F2 while on an element in the window or page).
    2. Position yourself at the end of the code of a global procedure.
    3. Type the prototype of procedure to create.
    4. Validate. The procedure is automatically created.
WEBDEV - Server codeWEBDEV - Browser code Remarks:
  • If the current code is a server code, the global procedure is created in the set of server procedures. If the current code is a browser code, the global procedure is created in the set of browser procedures.
  • To directly create a server global procedure, go to the "Code" tab, "Procedures" group, expand "New" and select "New global procedure (Server)".
  • To directly create a browser global procedure, go to the "Code" tab, "Procedures" group, expand "New" and select "New global procedure (Browser)".
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. Enter the name of the new procedure collection or select the used procedure collection.
  4. In the window that appears:
    • Enter the name of the global procedure to be created.
    • 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.
    • Indicate the scope of the procedure (visibility). The created procedure is public by default. For more details, see Public or private global procedure.
    • Indicate the role of the procedure: Undefined, Business, UI. By default, procedures have an "Undefined" role.
  5. Validate. 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 procedure collection in which the procedure is to be created:
    • If necessary, create a new collection of procedures ("New" option in the "Procedures" folder)..
    • Select the desired set of procedures.
      WEBDEV - Server codeWEBDEV - Browser code To create a global server or browser procedure, select the corresponding set of procedures.
  3. From the procedure collection context menu, 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.
    • Indicate the scope of the procedure (visibility). The created procedure is public by default. For more details, see Public or private global procedure.
    • Indicate the role of the procedure: Undefined, Business, UI. By default, procedures have an "Undefined" role.
  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.
WEBDEV - Browser code Note: To display the list of browser global procedures, use the Ctrl + Alt + F8 key combination in the code editor.
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. Select the desired global procedure.
  4. Open the context menu of the procedure and select "Delete".
WEBDEV - Server codeWEBDEV - Browser code To delete a server or browser global procedure, select the corresponding set of procedures.
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 "Test procedure" from 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
By default, a global procedure is public: it can be accessed from any piece of code.
In some cases, it is necessary to restrict access to a global procedure by making it "Private".. In this case, the global procedure can only be accessed by another global procedure in the procedure collection..
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:
  • bar start is red: private procedure.
  • bar start is normal: public procedure.
Note: 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: 10/04/2024

Send a report | Local help