Click to See Complete Forum and Search --> : binary file output


help chris
January 7th, 2000, 01:44 PM
I'm having a little bit of trouble with writing data into a binary file. The following is my code:


Dim file as Integer
Open "tmp.bin" for binary as file
Put #file, , memBuf
Close file




the contents of memBuf are exactly how I want it to be. However, when I open up "tmp.bin" in a hex editor, there are 4 bytes of data at the beggining of the file, the second two bytes are the length of the entire file. I do not want those four bytes to be inserted. I assume it must be my use of the "Put" command, but I am not aware of any other command to write to a file. I would appriciate any pointers you all may have.

thanks

January 7th, 2000, 02:44 PM
it appears you want to open the file tmp.bin and then enter the string memBUF into it...
why not try it this why?

FileNo = FreeFile
Open "tmp.bin" for binary as FileNo
Write #FileNo, memBuf
close FileNo

help chris
January 7th, 2000, 03:31 PM
thanks for the reply. Using your method, it complained about opening the file as "binary" so I changed that back to "output". And using that it only inserted a single byte (always a quote - h22) at the beggining. So, while better then 4 bytes being inserted, still not good :(

Anyway, after poking around some more, I found the "Print" command. So, the following code worked:


Dim file as Integer
file = FreeFile
Open "tmp.bin" for Output as file
print #file, memBuf
Close file




Thanks for your response, got me on my way :)