|
|
|
|
|
- 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
Global procedure/function
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.
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).
- In the "Code" pane, in the "Procedures" group, scroll down to "New" and select "New global procedure" (keyboard shortcut Shift F4).
- 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.. - 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.
- 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:
- Open the code editor (press F2 while on an element in the window or page).
- Position yourself at the end of the code of a global procedure.
- 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: - Select the corresponding code.
- Select "New .. Create a global procedure containing the selected code" in the context menu.
- Enter the name of the new procedure collection or select the used procedure collection.
- 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.
- 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: - Select the "Procedures" folder.
- 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.
To create a global server or browser procedure, select the corresponding set of procedures.
- In the Context menu of the procedure collection, select the "New global procedure" option.
- 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.
- 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: - Click the bar of the procedure in the code editor.
- Select "Delete" in the context menu.
Deletion from the "Project explorer" pane To delete a global procedure from the "Project explorer" pane: - Select the "Procedures" folder.
- Select the desired set of procedures.
- Select the desired global procedure.
- Open the context menu of the procedure and select "Delete".
Test of a global procedure From the code editor To test a global procedure: - Display the global procedure in the code editor.
- Click "GO" in the quick access buttons.
- 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: - Select the "Procedures" folder in the "Project explorer" pane.
- Select the name of the global procedure whose test must be run.
- Select "Run the procedure test" in the context menu.
- 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: - Select the global procedure in the "Project explorer" pane.
- In the context menu of the procedure, select the new access mode::
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.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|