Jump to content
  • Advertisement
Sign in to follow this  
WWakerFAN

read/write binary files for different languages

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

i've developed my own map format that is written as a binary file however my game is being written in c++ and the program that writes the maps is made in VB6 and from what i've seen it appears that binary files are written differently in vb so i was wondering, how i could get vb to write the binary file the same way as c++ does?

Share this post


Link to post
Share on other sites
Advertisement
Write it byte for byte. I have little (or none) experience with the late VB's. But if your getting different data, I can only assume that it uses UTF-8 per default.

If you make sure you only write a char at time, there should be no difference in how the file is stored. Im also guessing that it might have some different ways of storing strings. Only guessing though, but that would be the first thing I'd check.

Have you tried looking over what data is being stored?

Share this post


Link to post
Share on other sites
You could always build a COM object in C++ and then just use that COM object in VB. For something as simple as writting/reading binary files it should be pretty easy.

~guyaton

Share this post


Link to post
Share on other sites
Private Type randomstruct
x As Single
y As Single
End Type

...

Open "C:\a.txt" For Binary As #1
Dim x As Long, v As String, t As randomstruct
v = "blah"
x = 5
t.x = 1
t.y = -35
Put #1, , x 'This will write the bytes 05 00 00 00
'That is how a 32-bit "Long" is stored in memory
'(little-endian)
Put #1, , v 'This will write the 4 bytes in the string "blah"
Put #1, , t 'This will write the 4 bytes in x and then the 4 bytes in y stored as 32-bit floats ("Singles") are stored in memory. (Theres some IEEE standard)

Share this post


Link to post
Share on other sites
You could always create a converter, have VB output to text should be possible but it will make it bigger, then create a C++ program to convert it. When I have my own file formats I usually do this anyway just because in my cases exporting the information is easy but maybe not in the proper arragment I would like for easy loading so I create a converter program to arrange it so I can load in everything very fast and easily.

-THACO

Share this post


Link to post
Share on other sites
What you have to do is write the file in Sequential Order, that's how C++ does it..

I had kind of a similar question a while ago and posted about it..maybe that thread will help..

Thread


At the end I post an example how I did it, you may have to switch to VB.net to do it exactly how I did it, but that shouldn't matter...check it out and let me know if that helps ya at all

ArchG

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!