Click to See Complete Forum and Search --> : Text File Manipulation Help


CloudWraith
April 9th, 2010, 11:22 AM
I haven't used visual studio in almost a decade and back then I used visual basic. I do have a background in programming with ansi c and c++ but not within visual studio and it has been about 10 years since I did programming.

I'm working on a c++ 2008 project that will read in a text file generated from another program and I have a couple of questions on best practice techniques.

Some background:
The text file is human readable and only delimited by spaces.
The text file is consistent in its format (thankfully).
The text file is appended to constantly as the generating program runs.
An event is generated then written to the text file which consists of about 20 lines of text.
I want to read each event and do some manipulation on values within the lines of text.

Here is what I'm thinking so far:
I need to create a class that stores an event's data.
I need to create an array of that class to hold multiple events
I need to read in the text file an event at a time, process the event text to get the desired variables and store them into the class and subsequent class array.
I need to add to the array as new events are read and processed.
I need to output the class data to a view including text values and possibly plotting a graph.

My questions:
Based on my needs can you recommend good resources (books, websites, videos, etc..) to learn how to do this in Visual Studio 2008/2010?
Should I be using MFC, CLI or some other coding variant

I've read a lot recently on working with text files using streamreader but I'm not sure where to start with the manipulation code. Currently I've got an OnFileOpen() function that uses an OpenFileDialog^ call to get the file but I'm not sure I want to do manipulation on the file contents in the OnFileOpen() function. Do I close the file, pass the FileName to a new function and reopen it to work with it?

Once I've created the CArray for the events how to I access this array in the OnDraw function of the view?

Thanks in advance,
CW

Alex F
April 11th, 2010, 02:54 AM
First decide what language you want to use. This problem may be solved by using unmanaged C++, or any .NET language. If you want to use unmanaged C++, decide what framework you want for writing user interface. MFC looks like a good choice.
If you want to use .NET, forget about C++/CLI and write in C# or VB .NET. C# is a native choice for C++ programmer, VB .NET is used by programmers with previous VB6 experience.
C++/CLI is hard to use and over-complicated language which should be used only for managed/unmanaged code interoperability. For any other tasks, there are better and more user-friendly languages.