Page 1 of 1

Binary Files

Posted: Fri Oct 05, 2007 7:28 am
by supernova
Hello qbasic fans. First time poster, long time qbasic fan. I was wondering how to access a binary file in qbasic. I know how to with a text file, but the project I am doing needs me to access a binary file.
I know it probably sound like a lame question, but I'm stumped.

Posted: Fri Oct 05, 2007 8:59 am
by Codemss
I believe you can do this with:
OPEN file$ FOR BINARY AS #1

CLOSE #1

But I don't know how to write to the file. Thought it was with POKE:

POKE p&, c
p& is the place where to poke c.
c is in the range of 0-255.

Posted: Fri Oct 05, 2007 10:10 am
by MystikShadows
Hi supernova,

I wrote a tutorial on binary file in this webste's e-zine. You can read it here: http://www.petesqbsite.com/sections/exp ... inaryfiles

How it helps, it teaches how to write and read binary files based on datatype and also with en example using user defined types.

Hope it helps.

Re: Binary Files

Posted: Fri Oct 05, 2007 3:58 pm
by Mac
[quote="supernova"]access a binary file in qbasic[/quote]Sounds funny, but it is really necessary to know WHY you need to "access a binary file". Otherwise, the only answer is a general tutorial on file access including OPEN FOR RANDOM and OPEN FOR BINARY, blah-blah-blah.

What do you want to accomplish? Why?

Example: I have an EXE which has a comment that says "Do Not Copy". I want to change it to "O.K. to Copy". (or whatever it is that you are trying to accomplish).

If the answer is "nothing in particular - just wondering" then hop on MystikShadows's tutorial.

Mac

Posted: Fri Oct 05, 2007 9:17 pm
by supernova
Thanks for the info guys.

Posted: Fri Oct 05, 2007 9:20 pm
by supernova
Were would the MystikShadows's tutorial be Mac? :?:

Posted: Fri Oct 05, 2007 9:21 pm
by supernova
Sorry, found it, I'm an idiot. :oops: