Jump to content

Converting a binary file to ascii


reinato

Recommended Posts

Hi Reinato:

Can't go through the whole thing, but the basic idea is as follows:

post-1144-1133376903.png?width=400

1) Read four bytes from a file.

2) Type cast the four bytes as a single.

3) Format the single into a string.

I've left lots of details for you to work out-- put all this in a loop, with the file refnum wired to a shift register so you get more than just the first data point, might have to skip some header info in your file, might want to do something with the formatted data (Write to another file?), etc. but this should point you in the general direction.

For some types of files, there might be an easier way to do this, but the approach I've shown above is pretty general, you should be able to adapt it to whatever your needs are-- some of the easier approaches might be less versatile.

Hope this helps at least a little, Best Regards, Louis

One more point--

Some possibility, depending on where the data came from, that you might have to reverse the order of the bytes after you read them & before you type cast them as single. If so, look under String Functions>Addition String Functions> reverse string.

Louis

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.