Hi,
I try to save two differents charts in a FileStream and Load these two charts with the same FileStream.
Savin g process:
procedure TForm1.SaveStreamBitBtnClick(Sender: TObject);
var
theStream:TFileStream;
begin
OpenDialog1.DefaultExt:='Tee';
OpenDialog1.FilterIndex:=1;
OpenDialog1.Filter:='Files Chart (*.Tee)|*.TEE';
OpenDialog1.Title:='Save TEE file';
If OpenDialog1.Execute then begin
theStream := TFileStream.Create(OpenDialog1.FileName,fmCreate);
SaveChartToStream(Chart1,thestream,true,false);
SaveChartToStream(Chart2,thestream,true,false);
theStream.Free;
end;
and loading process:
procedure TForm1.LoadStreamBitBtnClick(Sender: TObject);
var
theStream:TFileStream;
begin
OpenDialog1.DefaultExt:='Tee';
OpenDialog1.FilterIndex:=1;
OpenDialog1.Filter:='Files Chart (*.Tee)|*.TEE';
OpenDialog1.Title:='Load TEE file';
If OpenDialog1.Execute then begin
theStream := TFileStream.CreateOpenDialog1.FileName,fmOpenRead);
theStream.Seek(0,0);
LoadChartFromStream(TCustomChart(Chart1),theStream);
LoadChartFromStream(TCustomChart(Chart2),theStream);
Chart1.Repaint;
Chart2.Repaint;
theStream.Free;
end;
end;
This code work fine with
SaveChartToStream(Chart1,thestream,true,true);
and failed with
SaveChartToStream(Chart1,thestream,true,false);
More, if I clear chart with Chart.RemoveAllSeries after saving, the program stop after two cycles (save+load) with an access violation.
I have no event attached with charts.
Best regards
Dge
LoadChartFromStream failed in binary mode
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dge,
It works fine here using the code below. Could you please test if this works for you? If you use FreeAllSeries(nil), as shown below, really removes the previous series instances.
It works fine here using the code below. Could you please test if this works for you? If you use FreeAllSeries(nil), as shown below, really removes the previous series instances.
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
For i:=0 to Chart1.SeriesCount - 1 do
begin
Chart1[i].FillSampleValues();
Chart2[i].FillSampleValues();
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
theStream1, theStream2:TFileStream;
begin
theStream1 := TFileStream.Create('c:\temp\test1.tee',fmCreate);
theStream2 := TFileStream.Create('c:\temp\test2.tee',fmCreate);
SaveChartToStream(Chart1,thestream1,true,true);
SaveChartToStream(Chart2,thestream2,true,true);
Chart1.FreeAllSeries(nil);
Chart2.FreeAllSeries(nil);
theStream1.Free;
theStream2.Free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
theStream1, theStream2:TFileStream;
begin
theStream1 := TFileStream.Create('c:\temp\test1.tee',fmCreate);
theStream2 := TFileStream.Create('c:\temp\test2.tee',fmCreate);
SaveChartToStream(Chart1,thestream1,true,false);
SaveChartToStream(Chart2,thestream2,true,false);
Chart1.FreeAllSeries(nil);
Chart2.FreeAllSeries(nil);
theStream1.Free;
theStream2.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
theStream1, theStream2:TFileStream;
begin
theStream1 := TFileStream.Create('c:\temp\test1.tee',fmOpenRead);
theStream1.Seek(0,0);
theStream2 := TFileStream.Create('c:\temp\test2.tee',fmOpenRead);
theStream2.Seek(0,0);
LoadChartFromStream(TCustomChart(Chart1),theStream1);
LoadChartFromStream(TCustomChart(Chart2),theStream2);
theStream1.Free;
theStream2.Free;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Hi Narcis,
When I save ONE chart in ONE file there is no problem. If I try to save TWO charts in ONE file with streaming process in binary mode, the file is "invalid" but in text mode it is right. It seems that the separation between series data in the first chart and the start of the second chart is wrong. Under debug it seems that the data reading process don't end...
In your answer you say that my code works fine on your computer? (perhaps compiler's options are significant?).
Best regards
Dgé
When I save ONE chart in ONE file there is no problem. If I try to save TWO charts in ONE file with streaming process in binary mode, the file is "invalid" but in text mode it is right. It seems that the separation between series data in the first chart and the start of the second chart is wrong. Under debug it seems that the data reading process don't end...
In your answer you say that my code works fine on your computer? (perhaps compiler's options are significant?).
Best regards
Dgé
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dge,
No, I said that the code I posted works fine on my machine.In your answer you say that my code works fine on your computer? (perhaps compiler's options are significant?).
Do you mean that exporting both charts to the same .tee file? Could you please send us an example we can run "as-is" to reproduce your problem here? You can post your files at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup.Thank you for your FreeAllseries instead of RemoveAllSeries, it solve the exception problem in a cycle load/save). But the binary problem raise again.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dge,
Thanks for the project. We have been able to reproduce it and this is a bug, only works with text format. I've added it to our defect list to be fixed for future releases.
Thanks for the project. We have been able to reproduce it and this is a bug, only works with text format. I've added it to our defect list to be fixed for future releases.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Dge,
You're welcome. Please be aware at our Version Info web page to know when this issue (TV52010956) is fixed.
You're welcome. Please be aware at our Version Info web page to know when this issue (TV52010956) is fixed.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |