Solved

Capturing Data from ICS TWSocket Into a File?

Posted on 2004-04-13
7
256 Views
Last Modified: 2010-04-05
Currently i do like this and it gives me an out of memory exception after like few hours. It was supposed to capture a day's data and then save it into a file.

procedure TfmMain.MySocketDataAvailable(Sender: TObject; Error: Word);
var
  SocketData: String;

begin
  SocketData := MySocket.ReceiveStr;
 // process SocketData here, code's been taken out
  try
    FCapturedData := FCapturedData + SocketData;
  except
    on E: Exception do
      lbException.Caption := 'Exception on capturing data: ' + E.Message;
  end;
end;

Maybe i should save the captured string into a file and then append like every hour or after the string size reach a predefine limit. But i think this will slow down the program as the captured string need to be appended to file for several times or more?

Any better solution?
0
Comment
Question by:coole
  • 3
7 Comments
 
LVL 7

Expert Comment

by:sftweng
ID: 10821338
Instead of concatenating SocketData to a single string (FCapturedData), why not add it as a new line to a hidden TMemo or TStringList which you occasionally write out to a disk file?
0
 

Author Comment

by:coole
ID: 10829514
Because i would like the data to be in it's original format so that i can playback the file with hyper terminal. Memo or StringList will store in a delimited format right unless i concatenate them into a string again?
0
 
LVL 7

Accepted Solution

by:
sftweng earned 125 total points
ID: 10829572
I suspect a single string is too small to hold all of your data, so you're going to have to use more than one; a TStringList seems to me to be the best alternative. For playback purposes, you can just ignore the string boundaries.
0
 
LVL 7

Expert Comment

by:sftweng
ID: 13190262
I believe I earned these points
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now