Reading / writing file created by C++ MFC application

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
supremisewan
Posts: 3
Joined: Fri Jun 25, 2010 11:34 am

Reading / writing file created by C++ MFC application

Post by supremisewan » Fri Jun 25, 2010 11:40 am

Hi folks, long time lurker first post here.

Does anyone have any experience of reading & writing a file created by another MFC application?
The application is placing arrays into a file.

Thanks

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Reading / writing file created by C++ MFC application

Post by Klaus » Fri Jun 25, 2010 1:08 pm

Hi supremisewan,

I have no idea what a MFC application is, but here some questions that may help us help you :D

1. Is this a plain text or binary file?
2. If it is a text file, do you know HOW (format) the arrays are written to that file?
3. Mabe you could post an example of these files here?


Best form germany

Klaus

supremisewan
Posts: 3
Joined: Fri Jun 25, 2010 11:34 am

Re: Reading / writing file created by C++ MFC application

Post by supremisewan » Sat Jun 26, 2010 1:27 am

Hi Klaus

Thanks for your quick reply.

MFC is Microsoft Foundation Class libraries. We use the CArchive class (part of mfc) to serialize the objects for the file. The applications are c++ MFC applications.

I know the exact format of the files (there are several different types) all are unicode binary files.
They generally contain a mixture of information, header, filetype (internal version number) Then a series of arrays-
for example a typical basic structure would be -

(index, array(position1, position2, position3), attribute, attribute) (index2, array(position4, position5), attribute, attribute)

Im not even 100% if this will even be possible in revolution without an external, but i have my fingers crossed.





I have figured out how to get rev to read the binary file, and process different types as binary, what is stumping me is how to deal with the arrays.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Reading / writing file created by C++ MFC application

Post by mwieder » Sat Jun 26, 2010 6:37 am

Well, if you've figured out how to extract the various binary formats you've already done the hard part <g>. You'll have to do some more reverse engineering to figure out the stored format of the data (whether it's packed, etc), but from that point on it's just a matter of reading a certain number of bytes and converting them. No external necessary.

BTW: Your "basic structure" looks like structs rather than arrays. If that's the case, then "array(position1, position2, position3)" will evaluate to a known type (int, real, etc) and you can go from there.

supremisewan
Posts: 3
Joined: Fri Jun 25, 2010 11:34 am

Re: Reading / writing file created by C++ MFC application

Post by supremisewan » Mon Jul 19, 2010 9:40 pm

thanks for the replys, really helped!

managed to get the decoding working, now im looking at the encoding side.

Getting there slowly.

I have another question. i need to encode a lat/long pair
using......................

bits-32/1 (Longitude) In WGS.84 in two’s complement.
Range -180 £ longitude < 180 deg.
(LSB) = 180/2 to the power 25 degrees

for example - i have the values 51.770302, -4.061172

am i right in thinking that revolution uses twos complement internally?, and i would be safe enough using--

put binaryEncode ("f*",(tdata[1]*128)) into theLatLong
put binaryEncode ("f*",(tdata[2]*128)) after the last item of theLatLong

Post Reply