[Lazarus] TStringList error

Cesar Romero cesarliws at gmail.com
Mon Jul 21 16:02:40 CEST 2008


This is not a error, as you can see is a warning.
The erros that you are not creating a instance of TStringList.
Before use list you should create the object.


List:= TStringList.Create;
try
  // your code here

finally
  List.Free;
end;

Bob K. escreveu:
> I'm getting the error: *unit1.pas(48,3) Warning: Local variable "List" 
> does not seem to be initialized*
>  
> Here's the code (which used to work):
>  
> unit Unit1;
>  
> {$mode objfpc}{$H+}
>  
> interface
>  
> uses
>   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
>   ZConnection, ZDataset, db, DBGrids, DbCtrls, SdfData, StdCtrls;
>  
> type
>  
>   { TForm1 }
>  
>   TForm1 = class(TForm)
>     Datasource1: TDatasource;
>     Datasource2: TDatasource;
>     DBGrid1: TDBGrid;
>     DBNavigator1: TDBNavigator;
>     ZConnection1: TZConnection;
>     ZTable1: TZTable;
>     ZTable2: TZTable;
>     procedure Button1Click(Sender: TObject);
>     procedure FormCreate(Sender: TObject);
>   private
>     { private declarations }
>   public
>     { public declarations }
>   end;
>  
> var
>   Form1: TForm1;
>  
> implementation
>  
> { TForm1 }
>  
> procedure TForm1.FormCreate(Sender: TObject);
> *var
>   List: TStringList*;
> begin
>  
>   ZConnection1.Connected:=True;
>  
>   ZTable1.Active:=True;
>   ZTable2.Active:=True;
>  
> *  list.Add('here');*
>  {
>   while not ZTable2.EOF do
>     begin
>       List.Add(ZTable2.FieldByName('MAKE').AsString);
>       ZTable2.Next;
>     end; //while
>  }
>     //showmessage(list.Strings[0]);
>  //  DBGrid1.Columns[0].PickList:=List;
>  
> end;
>  
> procedure TForm1.Button1Click(Sender: TObject);
> begin
>   end;
>  
> initialization
>   {$I unit1.lrs}
> end.
>  
> What has happened?
>  
> bob k.
>
>                                           
> ------------------------------------------------------------------------
>
> _______________________________________________
> Lazarus mailing list
> Lazarus at lazarus.freepascal.org
> http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
>   


-- 
Cesar Romero
http://blogs.liws.com.br/cesar
http://blogs.liws.com.br/cesar/?feed=




More information about the Lazarus mailing list