Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An example of declaring vars. in Interface Section

Status
Not open for further replies.

Pontelo

Programmer
Dec 18, 2001
80
BR
Please state me an example on how to declare
variables in Interface Section

Thank You !
 
unit myunit;

interface

uses global_var1 : integer;
global_var2 : integer;

implementation

uses local_var1 : integer;
local_var2 : integer;

end.

 
In case you are confused, the above example should be as follows (var instead of uses):-
Code:
interface

    var global_var1 : integer;
         global_var2 : integer;    

  implementation
  
    var local_var1 : integer;
         local_var2 : integer;

  end.
Note that when you create a new application in Delphi, the IDE generates code that has a variable in the interface section. Form1 is a variable. Simply add your interface variables after the Form1 declaration.
Code:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.DFM}
end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top