Programming for software intermingling(?)

This topic is 1327 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I would consider myself intermediate in the strictest terms. I've never used c++ to control other software so that is the most difficult portion I see. As of all this back and forth, 'Api's' was the word I apparently was looking for lol. Learning the correct Api's will be my focus moving forward. Any good resources for Api's through c or c++?

Share on other sites

I would consider myself intermediate in the strictest terms. I've never used c++ to control other software so that is the most difficult portion I see. As of all this back and forth, 'Api's' was the word I apparently was looking for lol. Learning the correct Api's will be my focus moving forward. Any good resources for Api's through c or c++?

The documentation for whatever API you intend to use tends to be a good start.

From what i understand you don't actually need to "control" other software though, it sounds as if all you need to do is read the contents of those .dat files and generate new files based on their contents.

Share on other sites
And what is the best method of reading .dat files and having my code understand which portions to change if wrong and which ones to record? Since another software im using generated the .dat and I'll be accessing it through my code.

Share on other sites
There is no such thing as "a .dat file". The three letters mean absolutely nothing. I could rename it to FOO or BAR or (on suitably modern OSes) GIBBERISH and the data would be unaffected. So there is no method for "reading .dat files" because the stuff in the file could literally be anything.

What we've been asking for is an example of what is inside this file. You need to open the file in a hex editor or other tool and look at the data inside it.

Share on other sites

The format of those files is probably application specific. You need to either:

-Find documentation for the file format (for the specific application, not for .dat files in general)

-Reverse engineer the file format yourself to figure out how information is stored in it

Share on other sites

And what is the best method of reading .dat files and having my code understand which portions to change if wrong and which ones to record?

That requires you to know the format of the file. The '.dat' file extension is just a generic notation for files containing data - there isn't any implied structure to the data.

To do anything useful with the data, you have to know how it is formatted. Either by reading a format specification provided by the author of the software which created that file, or by opening up the file in a text/hex editor, and reverse-engineering the structure.

If you open up the file in Notepad and you find you can read the contents easily, then it is a plain-text format, and will be fairly easy to interpret. If you open it in Notepad and it is just gibberish, then it is a binary format, and reverse engineering will be a painstaking process conducted with a hex editor, and healthy supply of caffeinated beverages.

If you are able to upload a sample of such a file, one of us can take a look and tell you if this is feasible.

Share on other sites

Thanks so much guys!!! It's easily read through notepad, so I'm getting the feeling this won't be too hard. So, since I know it's plain-text format, what do I need to do next? I assume what I'm reading are variables but I need to know how to check the values since they will change depending on the file. Here is what it reads like in the notepad:

**Note if I'm doing anything wrong looking at this file through a Hex editor or posting this let me know. I don't want to be doing anything illegal or unethical. I'm just trying to create something to read these and determine if it is good or needs to be changed.

*edit deleted code. (nothing was too important)



Edited by lb2024

Share on other sites

Ok, yes, that data format is dead simple. Basically an INI file, with the additional of tab-delimited columns.

You may well find there is an off-the-shelf INI parsing library that would load this, but if not, you want to follow the basic steps:

- open the file, read it a line at a time:

+ if the first character is a '#', ignore the line

+ if the first character is an '<', treat it as a section header

+ if the line contains a '=', assume everything up to the '=' is the key name, everything after is values separated by tabs

Probably simple enough you can get away with using a C-style scanf() to parse the actual values.

Edited by swiftcoder

Share on other sites

But to recheck before I cry triumph, let me gather if I got my logic down right.

For me to check a folder and it's content, I will need to learn about "api's" (ie. I have a folder with data and a txt file in which shows what should be in the folder I use some type of reader to crosscheck txt file and filenames in folder)

For me to check the values of the contents of my data file, I load the data file into possibly scanf() and search for specific strings and record my values. I then will print out the values in a txt format for use later.

I still haven't figured out how to input it into excel automatically, but I'm assuming the "api's" will have something to do with it.

Am I on the right track?

Share on other sites

Sort of. In brief:

- Reading files is built into the C++ standard library. Go learn about file streams.

- Parsing values from text can be accomplished in many ways, you'll probably either want to use file streams directly or the scanf() functions.

- Directory manipulation is not built into C++, so you might look at the aforementioned boost::filesystem.

- Modifying Excel files is not built in either, but there are 3rd-party libraries to help you out.

That said, I don't at this point have a good feel for your experience programming in C++, so a bunch of that may require significant other reading before you tackle it.