green text is being edited and should not be considered
relevant to the tutorial. for a while, it will make up
the bulk of this section.
black text has been edited to be more accurate with
regards to puppybasic.
........................................................................
working with binary files
1 of 7
an intro to puppybasic
chapter 9: working with binary files
........................................................................
........................................................................
working with binary files
2 of 7
it might be fun at this point to learn how to save and load some data in
a file, but this will be much more useful when you've learned about
decision making and loops. in the meantime, here is how to work with
binary files:
first of all, be sure to use this statement at the beginning of your
program:
DIM bt AS STRING * 1
so that you have a one byte string to work with. you can make longer
strings, but this one will work for any purpose.
........................................................................
........................................................................
working with binary files
3 of 7
always open the file :)
OPEN "filename.txt" FOR BINARY AS #1
if you are only going to read the file, you dont strictly need the bt
variable, and therefore don't need to DIM at the start of your program.
just INPUT a byte:
b$=INPUT$(1, #1)
and that's all there is to that. yes, it IS similar to keyboard input.
........................................................................
........................................................................
working with binary files
4 of 7
do it again to read the next byte. usually, you'll probably want to use
this method instead:
GET #1, q, bt
with q being the byte of the file you want to read... if q is 57, then
it will read the 57th byte of the file.
to write, use:
PUT #1, q, bt
where b is a string that's only one byte (or letter) long. it's pretty
much the same idea. some useful functions for working with files are:
........................................................................
........................................................................
working with binary files
5 of 7
q = FREEFILE
sets q to the number of the next filenumber that's free... if you've
opened a file as #1, and a second file, as #2, then FREEFILE will equal
3.
LOC(n)
is the byte you're set to read or write at. if you've used INPUT$(1, #1)
50 times already, LOC(1) will be 51.
........................................................................
........................................................................
working with binary files
6 of 7
LOF(n)
is worth remembering, LOF(n) is equal to the length of file #n, if you
open a file as #1 and the LOF(1) is 0, that file is empty.
always close the file when you're done working with it:
CLOSE #1
if you are only working with one file, or if you don't have any other
files that you need to leave open, using close with no file numbers:
........................................................................
........................................................................
working with binary files
7 of 7
CLOSE
will close all files.
-= end of chapter 9 =-
........................................................................
an intro to puppybasic (chapter 9)
this content is public domain.
........................................................................
click here to go back to the contents page
Before You Post, Please Note...
-> Please Note: By Posting, you agree to submit the contents of your post to the Public Domain <- SEE: howto post to this blog
Friday, February 2, 2007
puppybasic intro ch. 09 - working with binary files
Subscribe to:
Post Comments (Atom)
26 comments:
buy tramadol online buy tramadol cod shipping - tramadol hcl related substances
xanax online alprazolam 0.5mg tab purepac - 0.5 mg xanax effects
tramadol generic where can i buy tramadol usa - tramadol medication no prescription
generic xanax xanax length of effect - xanax high how much
buy tramadol online safe buy tramadol online - can tramadol for dogs get you high
buy tramadol online tramadol 50 mg over counter - order cheap tramadol online
buy carisoprodol soma carisoprodol wiki - carisoprodol soma indications
buy cheap carisoprodol carisoprodol dose erowid - carisoprodol opiate withdrawal
buy tramadol online tramadol 50 mg kaps ratiopharm - will 100mg tramadol do
buy cialis online generic cialis ervaringen - buy cialis online fast
tramadol no prescription buy generic tramadol no prescription - tramadol for dogs with liver disease
buy tramadol online no prescription tramadol vicodin high - buy tramadol cod overnight delivery
cialis pills best place buy cialis online us - cialis from us online pharmacy
cialis no rx generic cialis release date - cialis online andorra
buy cialis 10mg buy cialis kl - generic cialis viagra online
http://blog.dawn.com/dblog/buy/#85714 tramadol 60 mg - tramadol 50 mg and pregnancy
http://landvoicelearning.com/#57594 order tramadol online check - tramadol addiction symptoms
http://landvoicelearning.com/#23561 buy tramadol online forum - tramadol 800 mg day
best buy tramadol buy tramadol overnight delivery - buy tramadol online safe
buy tramadol online cod overnight tramadol recreational high - tramadol hydrochloride 100 mg side effects
http://reidmoody.com/#36921 ativan xanax together - ativan drug interactions
learn how to buy tramdadol buy tramadol online florida - does tramadol hcl 50 mg get you high
ativan price ativan for drug addiction - ativan gel side effects
http://staam.org/#56274 tramadol 100mg used - order tramadol online to florida
http://staam.org/#92453 tramadol for dogs dosage - buy tramadol online with mastercard
http://bayshorechryslerjeep.com/#8193 xanax withdrawal constipation - xanax overdose how many
Post a Comment