[Gambas-user] Read a binary file

Jussi Lahtinen jussi.lahtinen at ...626...
Sun Sep 18 14:13:51 CEST 2011


> I'm doing a little webserver in Gambas. Everything is ok so far, but I'm
> having a hard time dealing with binary files (like images). Is there a
> way to read a file in a raw fashion?
>
> I've tried to do an OPEN file FOR READ, and using a "byte" variable as
> buffer. But the bytes are read in this orden: 1, 0, 3, 2, 5, 4, 7, 6,
> etc... I think it's something about the endiannes.
>

Bytes should be read in logical order 0,1,2,3... but they might be written
in the file in order you describe.
You can read two bytes and swap them, or read them as type "short"..?
Send the piece of your code that does the attempted raw reading.

Usually I read binary files which are created by gambas program, so I
haven't ran into this problem.


Jussi



More information about the User mailing list