|
|
|
|
- Overview
- Procedures from a set of procedures
- Methods of a class
- Procedures of a control
- Summary table
- Scope changes
- Changing the scope of a procedure
- Migrating a project from an older version to version 28 or later
The scope of a procedure defines whether it is public, private, etc. This page presents the differences between the types of scope depending on the type of procedure, and how they affect your code. The scope of the procedures may include: - The procedures from a set of procedures.
- The methods of a class.
- The procedures of a control.
Procedures from a set of procedures There are different procedure scopes: By default, procedures are "Public". There are three possibilities: - Public procedure: The procedure can be used from any process or event of the project.
In a project used to generate a web service, the public procedure will be exported in the web service (it is a visible entry point of the web service). - Private procedure: The procedure cannot be used from another element of the project (sets of procedures, windows, etc.).
In a project used to generate a web service, the private procedure will not be exported in the web service. The procedure can only be called from the set of procedures in which it is defined. New in version 28Restricted procedure: The procedure can be used anywhere in the project, but cannot be exported in a web service or external component.
There are different class method scopes: By default, class methods are "Public". There are several possible cases: - Public method: the class method can be accessed from any element of the project and is exported when a web service or external component is generated.
New in version 28Restricted method: the class method can be used anywhere in the project, but it is not exported in external components or web services. - Protected method: the method can be accessed within the code of the class and derived classes only. The method is exported when an external component or a web service is generated.
New in version 28Protected restricted method: the scope is similar to "protected", but the method will not be exported in external components or web services. - Private method: the method can only be accessed within the code of the current class.
Some controls, such as the Smart controls included in the IDE, contain local procedures. These procedures can be public or private. Private procedures can only be used in the control they belong to. This allows you to isolate code and avoid unnecessary calls, for example: control A will not be able to call a procedure from control B. | | | | | Public | Restricted | Private | Access from the element | Yes | Yes | Yes | Access from another element of the project | Yes | Yes | No | Access from an external project via a web service or external component | Yes | No | No |
Changing the scope of a procedure To change the scope of a procedure or method at any time, you can do one of the following: - directly write the new scope in the code of the procedure or method,
- right-click the element in the "Project explorer" pane and select the desired scope.
The scope of a procedure or method can easily be determined according to the color of the icon in the "Project explorer" pane: - private elements are shown in red,
- protected elements are shown in orange,
- public elements are shown in green.
New in version 28Migrating a project from an older version to version 28 or later A new compilation error may appear when migrating projects from version 27 and earlier to version 28. This error indicates the "PRIVATE" keyword behaves differently.
Before version 28, the "Private" keyword had the same effect as the current "Restricted" keyword. When migrating a project to version 28, you may need to replace the "Private" keyword with "Restricted". A specific compilation error will help you detect the different cases in your project.
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|