Sign in to follow this  
Followers 0
Shanlar

FileRead and XVI32 Different Outputs?

3 posts in this topic

#1 ·  Posted (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 by Shanlar

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0