Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2000-04

Another one bug add: TMemo & TListBox I/Oerrors?

2 messages · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Shane Miller

I sent him this code to try. It's pretty simple.

The cool thing is I created it using Lazarus IDE and compiled it. A few issues exist (obviously) so the IDE isn't real usable. For example, when I click on a unit, the cursor still doesn't show up until I press a key!

Anyway, here's the project for loading a listview. Save these files into lazarus/testproject and run lazarus, PROJECT OPEN the .lpr file. PROJECT BUILD, then run it from a console....it works

Shane

>> 04/26/00 11:54AM >>>

+ From: Bogdan M.Maryniuck

+ >And finally, try to create a temporary TStringList and then assign to
+ >lines. I think this should be substantially faster (not tested).
+ How really better to do it? (Just code simple).

var
  S: TStringList;
begin
  S := TStringList.Create;
  S.LoadFromFile('your file name here');
  YourListBox.Items.Assign(S);
  S.Free;
end;

+ See, Delphi4 is loading without problems, so I mean that it is just
+ TListBox and TMemo bug or these components is too far from
+ the end for now

It might be an performance issue, the components are way from complete.

Marc

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus

unit unit1;
{$mode objfpc}
interface
uses
Classes, Messages, SysUtils, Graphics, Controls, Forms, Dialogs, Buttons,StdCtrls;
type
  TForm1 = class(TForm)
   ListBox1 : TListBox;
   Button1 : TButton;
   Edit1 : TEdit;
  private
    { Private declarations }
    Procedure Button1Click(sender : TObject);
  public
    { Public declarations }
  constructor Create(AOwner: TCOmponent);override;
  end;
var
  Form1: TForm1;
implementation
constructor TForm1.Create(AOwner: TComponent);
Begin
inherited create(AOwner);
Listbox1 := TListBox.Create(self);
   with Listbox1 do
  Begin
  Parent := self;
  Left := 0;
  Top := 0;
  Width := 300;
  Height := 300;
  Visible := True;
  end;
Button1 := TButton.Create(self);
   with Button1 do
  Begin
  Parent := self;
  Left := 350;
  Top := 0;
  Width := 100;
  Height := 50;
  Visible := True;
  Onclick := @Button1Click;
  Caption := 'Load File';
  end;
Edit1 := TEdit.Create(self);
   with Edit1 do
  Begin
  Parent := self;
  Left := 350;
  Top := 75;
  Width := 200;
  Height := 25;
  Visible := True;
  Text := '/var/log/cron/cron.info';
  end;
width := 550;
Height := 400;
end;
Procedure TForm1.Button1Click(Sender : TObject);
var
Texts : String;
I : Integer;
Begin
I := 0;
Listbox1.Items.LoadFromFile(Edit1.Text);
end;
end.
Program Project1;

uses
Forms,
Unit1;

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

[Modules]
Module0=/usr/lib/fpc/lazarus/testproject/test.lpr

Module1=/usr/lib/fpc/lazarus/testproject/unit1.pp
Count=2
EditWindowCount=1
[/usr/lib/fpc/lazarus/testproject/test.lpr]
ModuleType=SourceModule
FormState=0
FormOnTop=0

[/usr/lib/fpc/lazarus/testproject/unit1.pp]
ModuleType=SourceModule
FormState=0
FormOnTop=0

[EditWindow0]
ViewCount=1
CurrentView=0
View0=1

Visible=1
Left=57
Top=118
Height=600
Width=606
[View0]
Module=/usr/lib/fpc/lazarus/testproject/unit1.pp
CursorX=32
CursorY=74
TopLine=2
LeftCol=1

[Main Window]
Create=1
Visible=1
State=0
Left=4
Top=24
Width=1019
Height=125

[Message Window]
Create=1

State=0
Left=4
Top=24
Width=1019
Height=125
[Message WIndow]
Visible=0

Reply by email

Shane Miller

I was thinking maybe the EOF wasn't working so try this: Create a button with the onclick event doing a

if not(eof(file)) then
  Begin
   readln
   listbox.add
  end;

Click it until the eof
Does it crash? Hang? If so then the eof is a prob. If not then some other issue exists. Shane

>> 04/26/00 09:25AM >>>

Yes, it might be you need to add an Application.ProcessMessages. However, it should not be that thw whole application just freezes. Do you actually reach the end of the file (i.e. the bug may be in the Eof function)?
If the file is really large, it may take some time to add all the lines to a list box.
Also, be sure the sorting is off.
And finally, try to create a temporary TStringList and then assign to lines. I think this should be substantially faster (not tested).

Do you use GTK, Qt or Win32?

Michal Bukovjan

"Bogdan M.Maryniuck" wrote 70 lines
Ok, Marc. Here is detailed answer: begin readln(sometextfile,somestring); listbox.items.add(somestring); end; Here is all Ok -- I see my line there. When I try to (just for fun): begin readln(sometextfile,somestring); listbox.items.add(somestring); readln(sometextfile,somestring); listbox.items.add(somestring); readln(sometextfile,somestring); listbox.items.add(somestring); readln(sometextfile,somestring); listbox.items.add(somestring); readln(sometextfile,somestring); listbox.items.add(somestring); end; All RIGHT. And all OK. But: while not eof(sometextfile) do begin readln(sometextfile,somestring); listbox.items.add(somestring); end; It's freezing a system. Do I need to add: application.processmessages into the LOOP? Or what?.. Please help. ----- Original Message ----- From: Marc Weustink To: Sent: 26 rddl�? 2000 a. 5:47 Subject: RE: [lazarus] Another one bug add: TMemo & TListBox I/O errors? > + From: Bogdan M.Maryniuck > + > + Yes, it's work. Question is HOW. > + For example: > + > + while not eof(sometextfile) do > + begin > + readln(sometextfile,someasciistring); > + listbox.items.add(someasciistring); > + end; > + > + ...hanging a system and _NOT_ load a lines into a listbox. :-( > > How many lines are you trying to add? Have you tried one ? > > Marc > > > _________________________________________________________________ > To unsubscribe: mail with > "unsubscribe" as the Subject > archives at http://www.miraclec.com/list_archives/lazarus _________________________________________________________________ To unsubscribe: mail with "unsubscribe" as the Subject archives at http://www.miraclec.com/list_archives/lazarus

_________________________________________________________________ To unsubscribe: mail with
"unsubscribe" as the Subject
archives at http://www.miraclec.com/list_archives/lazarus

Reply by email