title: Declare public global variable in Delphi
body: <p>Let's say I have two forms in a delphi project, I want to be able to access form1's variables from form2. Is there anyone to declare, say a 'public' variable in form1 which can be read from all forms?</p>
  
  <p>I have tried putting a variable in the public declaration</p>
  
  <pre><code>    { private declarations }
    public
      { public declarations }
    test: integer;
    end;     
  </code></pre>
  
  <p>and in form 2 i have</p>
  
  <pre><code>    unit Unit2;
  
  {$mode objfpc}{$H+}
  
  interface
  
  uses
    Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, unit1;
  
  type
  
    { TForm2 }
  
    TForm2 = class(TForm)
      procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
      procedure FormCreate(Sender: TObject);
    private
      { private declarations }
    public
      { public declarations }
    end; 
  
  var
    Form2: TForm2; 
  implementation
  
  {$R *.lfm}
  
  { TForm2 }
  
  procedure TForm2.FormCreate(Sender: TObject);
  begin
    form1 //&lt;---------- DOES NOT GET RECOGNIZED
  end;
  
  end.
  </code></pre>
  
  <p>I then put 'Unit1' into the uses section on Form2, but it seems I can't do that due to a circular reference. I'd like to refrain from using pointers if possible.</p>