That was the important bit, together with his post.CK Guy is absolutely correct
Usefulness
Create a new file (Instead of opening and writing to an existing one)
You could just say
OPEN "file-that-doesn't-exist" FOR WRITE AS #1
(or whatever other filenumber you want) I think it's WRITE anyway, it might be OUTPUT.
Read/write input to a specified address in a file. (Instead of having to start from scratch when I open a file for input.)
For text files, you can open them up for writing, but keep everything that's already in them and just add on to the end of it by opening FOR APPEND. You can also open files FOR BINARY (or maybe its FOR RANDOM, sorry, I don't remember).
Combine two files
Probably the easiest way to do this is to have a SHELL command, running the DOS command "copy" in something like this:
COPY FILE_1 + FILE_2 COMBINED_FILE
You'll want to throw in a /B right after the word "copy" if you are combining binary (ie, non-text) files.
You could just say
OPEN "file-that-doesn't-exist" FOR WRITE AS #1
(or whatever other filenumber you want) I think it's WRITE anyway, it might be OUTPUT.
Read/write input to a specified address in a file. (Instead of having to start from scratch when I open a file for input.)
For text files, you can open them up for writing, but keep everything that's already in them and just add on to the end of it by opening FOR APPEND. You can also open files FOR BINARY (or maybe its FOR RANDOM, sorry, I don't remember).
Combine two files
Probably the easiest way to do this is to have a SHELL command, running the DOS command "copy" in something like this:
COPY FILE_1 + FILE_2 COMBINED_FILE
You'll want to throw in a /B right after the word "copy" if you are combining binary (ie, non-text) files.
- adurdin
- Site Founder
- Posts: 549
- Joined: Fri Aug 29, 2003 11:27 pm
- Location: Edinburgh, Scotland
- Contact:
If it's a text-only file:levellass wrote:Create a new file (Instead of opening and writing to an existing one)
Code: Select all
Open "new_file" for output as #1 'or another file number if you've used 1 already
Code: Select all
Open "new_file" for binary access write as #1
Use SEEK to seek to a particular byte in a file opened "for binary":Read/write input to a specified address in a file. (Instead of having to start from scratch when I open a file for input.)
Code: Select all
open "myfile" for binary access read as #1
dim dat as string * 20
seek #1, &H201
get #1,, dat ' read 20 bytes into the string from offset $200
...
open "otherfil" for binary access write as #1
seek #1, &H1A9
put #1,, dat ' write 20 bytes to offset $1A0
If you want to seek to a location relative to the end of the file, the LOF(filenumber) will give you the length in bytes of a binary file.
You can do this in various ways from QB, but using the SHELL statement to call the DOS copy command (as CK Guy suggested) is probably fastest:Combine two files
Code: Select all
SHELL "copy /b " + filename1$ + " " + filename2$ + " " + outputfilename$
So this shell command, does it work in Quick Basic? Could I instead read data from a specific address in one file then write it to another file? If so, what are the commands?
Ah, I though that worked only with existing files, excellent.You could just say
OPEN "file-that-doesn't-exist" FOR WRITE AS #1
- Freeyorp101
- Posts: 159
- Joined: Thu Nov 24, 2005 2:12 am
- Location: New Zealand
I have a beta of my Keen 1 Sprite Magic program; it can be found here:
http://levellord.toxicsheep.com/Keenstuff/MAGIC.zip
Read Readme.txt first or you won't have a clue what to do.
Please tell me what you think, problems encountered and features you'd like to see!
http://levellord.toxicsheep.com/Keenstuff/MAGIC.zip
Read Readme.txt first or you won't have a clue what to do.
Please tell me what you think, problems encountered and features you'd like to see!
- Freeyorp101
- Posts: 159
- Joined: Thu Nov 24, 2005 2:12 am
- Location: New Zealand
- CommanderSpleen
- Posts: 1017
- Joined: Sun Aug 31, 2003 12:11 pm
- Location: The Land of Sparkly Things
- Contact:
That's a very comprehensive and well-documented piece of work. I shall experiment.
I was away when you asked me about compiling to an EXE on MSN. You need QB version 4.5. If you like, I can email it to you.
I've uploaded a compiled version here.
I was away when you asked me about compiling to an EXE on MSN. You need QB version 4.5. If you like, I can email it to you.
I've uploaded a compiled version here.