Binary Files

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
supernova
Newbie
Posts: 7
Joined: Fri Oct 05, 2007 2:10 am
Location: australia

Binary Files

Post 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.
SYNTAX ERROR ...
User avatar
Codemss
Veteran
Posts: 124
Joined: Sun Jun 24, 2007 6:49 am
Location: Utrecht, The Netherlands
Contact:

Post 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.
Check out my site: <a href="http://members.lycos.nl/rubynl">Click here</a>
Hope you like it. Send some feedback if you want: <a href="mailto:basicallybest@live.nl">Mail me</a>
Codemss, before known as RubyNL
MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post 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.
When God created light, so too was born, the first Shadow!

MystikShadows

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com
Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Re: Binary Files

Post 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
supernova
Newbie
Posts: 7
Joined: Fri Oct 05, 2007 2:10 am
Location: australia

Post by supernova »

Thanks for the info guys.
SYNTAX ERROR ...
supernova
Newbie
Posts: 7
Joined: Fri Oct 05, 2007 2:10 am
Location: australia

Post by supernova »

Were would the MystikShadows's tutorial be Mac? :?:
SYNTAX ERROR ...
supernova
Newbie
Posts: 7
Joined: Fri Oct 05, 2007 2:10 am
Location: australia

Post by supernova »

Sorry, found it, I'm an idiot. :oops:
SYNTAX ERROR ...
Post Reply