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
  • Overview
  • Local procedure
  • Procedures local to a window
  • Procedures local to a page
  • Procedures local to a report
  • Procedures local to a control
  • Creating a local procedure
  • Creation from the code editor
  • Creation from the "Project explorer" pane
  • Displaying the list of local procedures
  • Deleting a local procedure
  • Public or private local procedure
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
Two types of procedures are available:
  • Global procedure: can be used in all project processes/events. This global procedure is stored in the project.
  • Local procedure: can be used in all processes/events dependent on the object (window, page, state or control) in which this procedure has been 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.
Local procedure
WINDEVAndroidiPhone/iPadIOS WidgetApple WatchJava

Procedures local to a window

Local procedures declared in a window can be called from all processes/events:
  • of the window,
  • of the window controls,
  • of the local procedures associated with the window.
These procedures are stored in the window.
Limits:
  • The local procedures of a window cannot be used by its sibling windows.
  • The local procedures declared in a child window cannot be used in its parent window.
WEBDEV - Server codeWEBDEV - Browser code

Procedures local to a page

Local procedures declared in a page can be called from all processes/events:
  • of the page,
  • of the page controls,
  • of the local procedures associated with the page.
These procedures are stored in the page.
You can declare in a page:
  • local server procedures. This type of local procedure contains WLanguage code that will be run on the server.
  • local browser procedures. This type of local procedure contains WLanguage code that will be run on the browser.
  • mixed local procedures. This type of procedure can be run on both the server and the browser. The code of this procedure must be compatible (it must work on both the server AND the browser).
Limit: Local server procedures on a page cannot call local browser procedures on a page, and vice versa.
Remark: Mixed local procedure: This type of procedure can run both on the server and on the browser.. The code of this procedure must be compatible (it must work on both the server AND the browser).
To use a specific server code and/or a specific browser code, you can use the following syntax:
<SI Navigateur>
// Code à exécuter uniquement sur le navigateur
<FIN>
<SI Serveur>
// Code à exécuter uniquement sur le serveur
<FIN>
WINDEVWEBDEV - Server codeWindowsiPhone/iPadIOS Widget

Procedures local to a report

Local procedures declared in a report can be called from all processes/events:
  • of the report,
  • of report controls,
  • of the local procedures associated with the report.
These procedures are stored in the report.

Procedures local to a control

Local procedures declared in a control can be called from all processes/events:
  • of the control,
  • of the local procedures associated with the control.
These procedures are stored with the control. When the control is copied, the local procedures associated with it will be copied.
You can make procedures local to controls in a window, page or report.
WEBDEV - Server codeWEBDEV - Browser code Only "server" procedures local to controls are available. You cannot make a browser procedure local to a control.
Creating a local procedure

Creation from the code editor

To create a procedure local to the current element from the code editor:
  • Method 1:
    1. Create the procedure:
      • WINDEVWINDEV Mobile To create a procedure local to a window, control or report, go to the "Code" tab, "Procedures" group, expand "New" and select "New local procedure" (or press F4).
      • WEBDEV - Server code To create a local server procedure for a page or page control: in the "Code" pane, in the "Procedures" group, pull down "New" and select "New local procedure (Server)".
      • WEBDEV - Browser code To create a browser-based local procedure for a page: in the "Code" pane, in the "Procedures" group, pull down "New" and select "New local procedure (Browser)".
    2. 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.
      • Indicate the role of the procedure: Undefined, Business, UI. By default, procedures have an "Undefined" role.
      • If the code editor shows the code of a control, the "Create the procedure within the control" option allows you to specify whether or not the local procedure should be associated with the control.
    3. Click "Add". The local procedure is created. The created procedure is public by default. For more details, see Public or private local procedure.
  • Method 2:
    1. Create the procedure:
      • WINDEVWINDEV Mobile To create a local procedure: select "New . New local procedure" from the context menu.
      • WEBDEV - Server code To create a local server procedure, select "New .. New local procedure (Server)".
      • WEBDEV - Browser code To create a local browser procedure, select "New .. New local procedure (Browser)".
    2. 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.
      • Indicate the role of the procedure: Undefined, Business, UI. By default, procedures have an "Undefined" role.
      • If the code editor shows the code of a control, the "Create the procedure within the control" option allows you to specify whether or not the local procedure should be associated with the control.
    3. Click "Add". The local procedure is created. The created procedure is public by default. For more details, see Public or private local procedure.
  • Method 3: To create a local procedure:
    1. Place the cursor in the "Global declarations" event of the window or page, in an event of the control or in the "Open" event of the report.
    2. Type the prototype of procedure to create.
    3. Validate. The local procedure is automatically created.
Note: To transform a piece of code already entered in a local procedure into a local procedure:
  1. Select the corresponding code.
  2. Select "New .. Create a local 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.
WEBDEV - Server codeWEBDEV - Browser code Note: If the selected code is a server code, the created procedure will be a server procedure.. If the selected code is a browser code, the created procedure will be a browser procedure.

Creation from the "Project explorer" pane

To create a local procedure from the "Project explorer" pane:
  1. Select the element associated with the local procedure (window, page, report, control, etc.).
  2. Expand the element options and select "Procedures".
    Note: If no procedure is associated with a field, the "Procedures" option is not displayed.. In this case, select the name of the control.
  3. Open the context menu.
  4. Select:
    • WINDEV "New procedure".
    • WEBDEV - Server code "New server procedure".
    • WEBDEV - Browser code "New browser procedure".
    • WEBDEV - Server codeWEBDEV - Browser code "New mixed procedure".
  5. In the window that appears:
    • Specify the name of new local 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 role of the procedure: Undefined, Business, UI. By default, procedures have an "Undefined" role.
  6. Click "Add". The local procedure is created. The created procedure is public by default. For more details, see Public or private local procedure.
  7. Validate.

Displaying the list of local procedures

To display the list of local procedures in the "Project explorer" pane, go to the code editor and press F8.
Deleting a local procedure
To delete a local procedure from the "Project explorer" pane:
  1. Select the element associated with the local procedure (window, page, report, control, etc.).
  2. Expand the element options.
  3. Expand "Procedures".
  4. Select the desired procedure.
  5. Open the context menu of the procedure and select "Delete".
Public or private local procedure
A local procedure is public by default: it can be accessed by any code.
In some cases, it is necessary to restrict access to a local procedure by making it "Private"..
When creating a local procedure, you have the ability to specify whether the procedure is public or private.
To modify the access mode to a local procedure:
  1. Select the local 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 local private or public procedures:
The use of private or public local procedures has an impact in the external components. Indeed, only the procedures explicitly declared as public (with the PUBLIC keyword used in their prototype) found in an external component cannot be accessed from 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: 09/20/2024

Send a report | Local help