learning my way through here lazarus / 10-Designer ---------------------------------------------------------------------- LearningTheRopes · 2004-12-30 07:21 Hello, First time posting here, if this is the wrong place for it, then you have deepest apology.   :oops: I have checked the archives for the past year and couldn't find what I was looking for.   :cry: Please examine the following code, more information at end: ----------------------------------------- unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Menus,   Unit2, StdCtrls; type   TForm1 = class(TForm)     MainMenu1: TMainMenu;     MenuItem1: TMenuItem;     MenuItem2: TMenuItem;     MenuItem3: TMenuItem;     StaticText1: TStaticText;     procedure MenuItem2Click(Sender: TObject);     procedure MenuItem3Click(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1;   MsgText: String; implementation { TForm1 } procedure TForm1.MenuItem3Click(Sender: TObject); begin   close; end; procedure TForm1.MenuItem2Click(Sender: TObject); begin   Form2.Show();   StaticText1.Caption := MsgText; end; initialization   {$I unit1.lrs} end. ----------------------------------------- unit Unit2; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons; type   TForm2 = class(TForm)     Button1: TButton;     procedure Button1Click(Sender: TObject);     procedure Form2Hide(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form2: TForm2;   MsgText : String; cvar; external;   implementation { TForm2 } procedure TForm2.Button1Click(Sender: TObject); begin   Form2Hide(Sender);   MsgText := 'Hello, all you young turkeys out there.'; end; procedure TForm2.Form2Hide(Sender: TObject); begin   Form2.Hide();   exit; end; initialization   {$I unit2.lrs} end. ----------------------------------------- In procedure TForm2.Button1Click(Sender: TObject); , if I was programming in Visual Basic 3 (oldie)     I could have written: Form1.StaticText1.Caption := 'Hello, all you young turkeys out there.'; Why can't I do this here? So I tried to do a 'global' varible that gets passed back so that Form1 can use it. In the second form, the 'so called' external varible MsgText is an 'Undefined Reference' -- that is the message I keep getting, along with 'error while linking'. So, how can I create a external varible that can be used in ALL units, and how can I 'send' back more than one result, that is, two or more varibles passed back to the calling routine. I am trying to learn this stuff, haven't program in pascal since the early to middle '80s.  Wish there were better docs for this stuff.  :roll: I am 'trying' to translate a c/cpp program into pascal (I'll need all the luck in the world - it seems.....)      :lol: Many thanks --- James ---------------------------------------------------------------------- Lightning · 2004-12-30 21:43 Get some Delphi books, go to the Lazarus-CCR website, you'll find tons of docs. For your problem the code should be: Code: [Select] implementation   uses Unit1; You must add the unit wich contains your first form to your uses clause of the other unit wich sets the properties to the first form, to avoid recursive usage you must add it after the implementation part wich is not global , Pascal didn't change that much, it only added stuff and became more flexible. ---------------------------------------------------------------------- Anonymous · 2004-12-31 08:00 Thanks for the tip, I will be adding that in and try it in a day or two. James