PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Overview
  • Local procedure
  • Procedures local to a page
  • Procedures local to a report
  • 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
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
Two types of procedures are available:
  • Global procedure: can be used in all the processes/events of the project. This global procedure is stored in the project.
  • Local procedure: can be used in all processes/events that depend on the object (window, page or report) 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 the procedures also apply to the functions.
  • Versions 16 and later
    You have the ability to create overloaded procedures. See Prototype overload for more details.
    New in version 16
    You have the ability to create overloaded procedures. See Prototype overload for more details.
    You have the ability to create overloaded procedures. See Prototype overload for more details.
Local procedure
WEBDEV - Server codeWEBDEV - Browser code

Procedures local to a page

The local procedures declared in a page can be called from all processes/events:
  • of the page,
  • of the page controls,
  • of 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.
  • Versions 24 and later
    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).
    New in version 24
    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).
    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: The local server procedures of a page cannot call the local browser procedures of a page and conversely.
Versions 24 and later
Remark: Mixed local procedure: 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).
To use a specific server code and/or a specific browser code, you can use the following syntax:
<IF Browser>
// Code to be run only on the browser
<END>
<IF Server>
// Code to be run only on the server
<END>
New in version 24
Remark: Mixed local procedure: 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).
To use a specific server code and/or a specific browser code, you can use the following syntax:
<IF Browser>
// Code to be run only on the browser
<END>
<IF Server>
// Code to be run only on the server
<END>
Remark: Mixed local procedure: 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).
To use a specific server code and/or a specific browser code, you can use the following syntax:
<IF Browser>
// Code to be run only on the browser
<END>
<IF Server>
// Code to be run only on the server
<END>
WEBDEV - Server codeWindows

Procedures local to a report

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

Creation from the code editor

To create a procedure local to the current element from the code editor:
  • Method 1:
    • WEBDEV - Server code To create a local server procedure, select "Insert .. New local procedure (Server)". WEBDEV - Server code To create a local server procedure: on the "Code" pane, in the "Procedures" group, expand "New" and select "New local procedure (Server)".
    • WEBDEV - Browser code To create a local browser procedure, select "Insert .. New local procedure (Browser)". WEBDEV - Browser code To create a local browser procedure: on the "Code" pane, in the "Procedures" group, expand "New" and select "New local procedure (Browser)".
    • In the window that is displayed:
  • Method 2:
    • WEBDEV - Server code To create a local server procedure, select "Create a procedure .. Create a local procedure (Server)". 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 "Create a procedure .. Create a local procedure (Browser)". WEBDEV - Browser code To create a local browser procedure, select "New .. New local procedure (Browser)".
    • In the window that is displayed:
  • Versions 22 and later
    Method 3: To create a local procedure:
    • Position the cursor in the event "Global declarations" of the window or page.
    • Type the prototype of procedure to create.
    • Validate. The local procedure is automatically created.
    New in version 22
    Method 3: To create a local procedure:
    • Position the cursor in the event "Global declarations" of the window or page.
    • Type the prototype of procedure to create.
    • Validate. The local procedure is automatically created.
    Method 3: To create a local procedure:
    • Position the cursor in the event "Global declarations" of the window or page.
    • Type the prototype of procedure to create.
    • Validate. The local procedure is automatically created.
Remark: To transform a section of code already entered in a local procedure into a local procedure:
  1. Select the corresponding code.
  2. Select "Create a procedure .. Create a procedure containing the selected code" from the popup menu.Select "New .. Create a local procedure containing the selected code" from the popup menu.
  3. Specify:
  4. The procedure is created, the corresponding code is replaced by the call to the procedure with the necessary parameters.
WEBDEV - Server codeWEBDEV - Browser code Remark: 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, ...).
  2. Expand the element options and select "Local procedures".
  3. Display the popup menu.
  4. Select:
    • WEBDEV - Server code "New local server procedure".
    • WEBDEV - Browser code "New local browser procedure".
    • Versions 24 and later
      WEBDEV - Server codeWEBDEV - Browser code "New mixed local procedure".
      New in version 24
      WEBDEV - Server codeWEBDEV - Browser code "New mixed local procedure".
      WEBDEV - Server codeWEBDEV - Browser code "New mixed local procedure".
  5. In the window that is displayed:
  6. Validate.

Displaying the list of local procedures

To display the list of local procedures, select "Display .. Local procedures" (or press F8) in the code editor.
WEBDEV - Server codeWEBDEV - Browser code By default, "Display .. Local procedures" lists the local server procedures. To display the list of local browser procedures, select "Display .. Local browser procedures" (or press Alt + F8) in the code editor.
To display the list of local procedures, press F8 in the code editor. The list of local procedures is displayed in the project explorer.
WEBDEV - Server codeWEBDEV - Browser code By default, the F8 key lists the local server procedures. To display the list of local browser procedures, press Alt + F8 in the code editor. The list of local procedures is displayed in the project explorer.
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, ...).
  2. Expand the element options.
  3. Expand the "Local procedures" option of the element.
  4. Select the requested procedure.
  5. Display the popup menu of the procedure and select "Delete".
Public or private local procedure
A local procedure is public by default: it is accessible from any code.
In some cases, it may be useful to restrict the access to a local procedure by making it "Private".
Versions 19 and later
When creating a local procedure, you have the ability to specify whether the procedure is public or private.
New in version 19
When creating a local procedure, you have the ability to specify whether the procedure is public or 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 popup menu of the procedure, select the new access mode::
    • public.
    • private.
Versions 16 and later
The color of the procedure bar changes according to its access mode:
  • red beginning of bar: private procedure.
  • standard beginning of bar: public procedure.
New in version 16
The color of the procedure bar changes according to its access mode:
  • red beginning of bar: private procedure.
  • standard beginning of bar: public procedure.
The color of the procedure bar changes according to its access mode:
  • red beginning of bar: private procedure.
  • standard beginning of bar: public procedure.
Note: External component and private or public local 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