Jump to content

Reading a file problem


Recommended Posts

Hi,

Trying to read a file. It's a binary config file. When I use DOS's 'type' command I see characters.

Really what I want to do is something like the command 'strings' in UNIX: show the strings in a binary. However I will settle for just the whole output of the file.

The problem is that due to the binary status of the file (I'm guessing), I can only seem to get the first character of the file.

I've tried several things, for example this:

$test = FileRead('c:\test.file')
msgbox(0,'title', $test)

That just shows me the first character of the file. I've tried messing around with BinarytoString as well.

Help! =]

Link to comment
Share on other sites

$in=FileOpen("C:\ifOutput.txt",16)
$out=FileOpen("C:\ifOutput2.txt",2)
$data=FileRead($in)
FileWrite($out,$data)
MsgBox(0,"","binary"&IsBinary($data))
MsgBox(0,"",binarytostring($data))
msgbox(0,"","here")

If I run this code, only one message box ever opens. I think there is a bug in the binarytostring function (?)

Link to comment
Share on other sites

I'm trying to get the 'text' from a binary, without all the 'other' characters which seem to screw up autoit.

The way I arrived at that conclusion is that if I try to convert to string, the script just hangs forever and I need to force kill it.

Link to comment
Share on other sites

  • Developers

I'm trying to get the 'text' from a binary, without all the 'other' characters which seem to screw up autoit.

The way I arrived at that conclusion is that if I try to convert to string, the script just hangs forever and I need to force kill it.

You are reading the whole file in one time into a binary field and then you convert the whole thing back to a string.

Is that what you want to do or maybe something else?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...