Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Product Manuals » Elevate Web Builder 3 Manual » Language Reference » Scope |
unit Unit1; interface // Public to this unit and all referencing units implementation // Private to this unit end.
// Parameters are private to the function function MyFunction(const MyParameter: String): String; var MyVariable: String; // Variables are private to the function begin end;
interface type TClassA = class private FMemberVariable: String; protected procedure DoSomethingMethod; public property MemberProperty: String read FMemberVariable; end; TClassB = class(TClassA) public procedure DoSomethingElseMethod; end; implementation { TClassA Implementation } procedure TClassA.DoSomethingMethod; begin FMemberVariable := 'Test'; // Can access this variable because it is also // declared within the TClassA declaration end; { TClassB Implementation } procedure TClassB.DoSomethingElseMethod; begin DoSomethingMethod; // Can access this protected method because it is // declared within the ancestor TClassA declaration end;
Scope | Description |
Private | Any member variables, properties, or methods declared in this scope are only visible to the properties or methods of the same class declaration. |
Protected | Any member variables, properties, or methods declared in this scope are only visible to the properties or methods of the same class declaration, or any descendant class declarations. |
Public | Any member variables, properties, or methods declared in this scope are visible everywhere, subject to the scoping rules of the referencing declaration or code block. |
Published | Same as Public, but in addition, all properties declared in this scope are streamable and will appear in the IDE's component inspector. |
interface type TMyClass = class private MyVariable: String; procedure MyMethod; end; implementation procedure TMyClass.MyMethod; var MyVariable: String; // This declaration overrides the scope of the class begin MyVariable := 'Test'; // This will be assigned to the local // MyVariable variable Self.MyVariable := 'Test'; // This will be assigned to the MyVariable member // variable of the TMyClass class end;
This web page was last updated on Thursday, November 16, 2023 at 10:39 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |