How to "Simple Database" lazarus / 16-Databases ---------------------------------------------------------------------- StaticStupid · 2010-10-24 12:26 Hi, i am newbie in Lazarus, I need help about making "simple database" In further explanation: I have form1 which have Label1 and Button1, In Lazarus my label1.caption:='Lazarus Test', my button1Click is set to open form2, and in form2 i have Edit1 component and another button2 which will be button2.caption:='Save'. So i want when i change the text in Edit1 and when i press Save (button2), i want label1.caption to be changed in edit1.caption. And when i Close my program, label1.caption to be saved with edit1.caption's name. I hope i explained it well. ---------------------------------------------------------------------- xenblaise · 2010-10-25 01:47 //this is unit1 uses unit2,....,.... ... type private fromunit2: TForm2; public end; ... ... begin fromunit2.Label1.caption := 'xxx'; end; //this is unit2 uses unit1,....,.... ... type private fromunit1: TForm1; public end; ... ... begin fromunit1.Label1.caption := 'xxx'; end; Quotesorry, my sight are wrong, I forgot, but below is the correct usage. ---------------------------------------------------------------------- StaticStupid · 2010-10-25 09:17 If don't mind you, can you explain this a little more i mean: Code: [Select] Private Fromunit1: TForm1; Public End; <- How come... And my program won't compile can't read TForm1/TForm2, and yeah i put uses unit1, uses unit2, under 'implementation'. ---------------------------------------------------------------------- xenblaise · 2010-10-25 13:28 Quoteunit Unit1; {$mode objfpc}{$H+}   interface uses   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,   StdCtrls; type   TForm1 = class(TForm)     Button1: TButton;     Label1: TLabel;     procedure Button1Click(Sender: TObject);   private     { Private declarations }   public     { Public declarations }   end; var   Form1: TForm1; implementation uses unit2; procedure TForm1.Button1Click(Sender: TObject); begin Form2.Show; Form2.Label1.Caption := 'this is label1 in form_2 called by form_1'; end; initialization   {$I unit1.lrs} end. Quoteunit Unit2; {$mode objfpc}{$H+}   interface uses   Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,   StdCtrls; type   TForm2 = class(TForm)     Button1: TButton;     Label1: TLabel;     procedure Button1Click(Sender: TObject);   private     { Private declarations }   public     { Public declarations }   end; var   Form2: TForm2; implementation uses unit1; procedure TForm2.Button1Click(Sender: TObject); begin Form1.Show; Form1.Label1.Caption := 'this is label1 in form_1 called by form_2'; end; initialization   {$I unit2.lrs} end. ---------------------------------------------------------------------- xenblaise · 2010-10-25 13:37 if you need better sample project code for databases; take a look at this link; http://forum.lazarus.freepascal.org/index.php/topic,10811.0.html read carefully for good understanding. ---------------------------------------------------------------------- 99Percent · 2010-10-25 13:42 Code: [Select]Unit Unit1; Uses Unit2; . . . Procedure TForm1.Button1Click(Sender: TObject); begin   with TForm2.Create(self) do if showmodal=mrOk then Label1.Caption:=Edit1.Text; end; Procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction); begin    with TStringList.Create do begin Text:=Label1.Caption; SaveToFile('yourfilename.txt'); end; end; In project options>forms take off Form2 from the auto-create forms list and put it in the available forms colums. In Form2 Button2 should be TBitBtn type with Kind property set to bkOk; ---------------------------------------------------------------------- StaticStupid · 2010-10-26 08:56 http://img541.imageshack.us/img541/1216/saving.jpg When i will close my program, and after when i open it, i want label1 in form1 to be named: Text1 in this case. up there is my "program" Please if you want make the program like in my photo, and after post full code, i will understand from full, but doing just parts confuses me, i said i am beginner. ---------------------------------------------------------------------- StaticStupid · 2010-10-29 23:34 bump, everything is ok with 'SaveToFile', but how to 'LoadFromFile' this thing won't work, i tried some examples, searched on google i tried it but i can't make it work.... In your example doesn't have Loadfromfile, neither it can Load the already saved text in my Edit1, showed in label1, so maybe 'LoadFromFIle' can help me out, but i need the right code. edit please watch your language. Marc ---------------------------------------------------------------------- 99Percent · 2010-10-29 23:50 Code: [Select] with TStringList.Create do begin LoadFromFile('yourfilename.txt'); Label1.Caption:=Text; end; TStringList object is extremely powerful and useful. You can add many strings (Add procedure), order them, pair them with = sign (for example Label1=xxx). I suggest you study it thoroughly, it will pay off. ---------------------------------------------------------------------- StaticStupid · 2010-10-30 15:47 Yummy love you! Thank you very much, it works now, and thank you for the suggestion! Edit & Warning: sorry i didn't mean to use it, my hands wrote it before my brain to think about.