[Gambas-user] How do I manipulate binary files?

Fredrik Hansson fredrik_hansson at ...1788...
Mon Oct 29 15:14:13 CET 2007


Hi,

I would like to write chars (bytes) directly into an OpenOffice file.
The file is a document, a template, and at specific places I want to put
in the right letters. In that way my application can fill in a form made
in OpenOffice automatically. An old trick that used to work in
Windows...

But here's the problem: I read byte by byte from the document file.
I look for specific words there (by combining the last 4 bytes for
example).

I have put field markers in the document, like H#01, but I can't find
them when I'm reading the bytes. Shouldn't 'H' have the code 72 and '#'
the code 35 for example? Or is that old ASCII not used in
Linux/OpenOffice? Or am I using the wrong method when I try to read the
file?

  DIM b AS Byte
  DIM fil AS file
  fil = OPEN "document.odt" FOR READ
  WHILE NOT Eof(fil)
    READ #fil, b
    IF b = 72 THEN 'look for the letter H
    (etc)

Anyone have a clue?
/Fredrik





More information about the User mailing list