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
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
WINDEVWEBDEV - Server codeReports and QueriesUniversal Windows 10 AppAndroidAndroid 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 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".
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)
Remark: A set of global browser procedures is converted into a set 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: The global server procedures cannot call the global browser procedures (and conversely).
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. In the "Code" pane, in the "Procedures" group, scroll down to "New" and select "New global procedure" (keyboard shortcut Shift F4).
    3. Enter the name of the collection of procedures containing the global procedure and validate..
      Remark: 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.
      • Specify 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.
    Remark: You can also use the "New . New Empty Global Procedure" option in the Context menu of a line of code.
  • 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 create a global server procedure directly, in the "Code" pane, in the "Procedures" group, pull down "New" and select "New global procedure (Server)".
  • To create a global procedure browser directly, in the "Code" pane, in the "Procedures" group, scroll down to "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.
    • Specify 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. In the Context menu of the procedure collection, select the "New global procedure" option.
  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.
    • Specify 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 Remark: To display the list of global browser procedures, press Ctrl + Alt + F8 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 "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: 07/02/2024

Send a report | Local help