Shanlar Posted July 2, 2008 Share Posted July 2, 2008 (edited) My goal is to read a .dat file, change a few bytes in it and write it out to another .dat file. But my current problem is that FileRead is outputting different information from what XVI32 is outputting. I can't seem to figure out what the issue is, any help would be greatly appreciated. $handle = FileOpen(@ScriptDir & '\test.dat') $data = FileRead($handle, 0+16) FileClose($handle) Msgbox(0,"Data",$data) Zipped and attached is the file I have been testing with. It outputs the correct 1/4 of the file correctly, but then gets off track and by the end of the file it is completely wrong. Edited July 2, 2008 by Shanlar Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 2, 2008 Moderators Share Posted July 2, 2008 (edited) Well without downloading, looks to me that you have your FileRead second parameter confused. That's how many bytes you want to read, not what type of file you want to read. You're probably wanting to use FileOpen("test.dat", 16): $handle = FileOpen(@ScriptDir & '\test.dat', 16) $data = FileRead($handle) FileClose($handle) Msgbox(0,"Data",$data) Edit: BTW, MsgBox probably isn't the best way to be looking at the output data, write it to another file (in binary of course). Edited July 2, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Shanlar Posted July 2, 2008 Author Share Posted July 2, 2008 Well without downloading, looks to me that you have your FileRead second parameter confused. That's how many bytes you want to read, not what type of file you want to read. You're probably wanting to use FileOpen("test.dat", 16): $handle = FileOpen(@ScriptDir & '\test.dat', 16) $data = FileRead($handle) FileClose($handle) Msgbox(0,"Data",$data) Edit: BTW, MsgBox probably isn't the best way to be looking at the output data, write it to another file (in binary of course). Yea my sample code was all kinds of incorrect heh. The night is starting to wear on me. I finally got it working, I think it had to do with some concat strings I had that were throwing things off. All is good now. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now