Usefulness

Request patches for Keens 1-3.
User avatar
adurdin
Site Founder
Posts: 549
Joined: Fri Aug 29, 2003 11:27 pm
Location: Edinburgh, Scotland
Contact:

Post by adurdin »

CK Guy is absolutely correct
That was the important bit, together with his post.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Yes, it seems so. And it highlights another problem I was wondering about; I hadn't been calling the random number subroutine! All those errors from one stupid mistake! (This brings my successful patch rate up from 1/3 to 1/2.)
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Is there any way I can do any of the following in Quick Basic?;

Create a new file (Instead of opening and writing to an existing one)

Read/write input to a specified address in a file. (Instead of having to start from scratch when I open a file for input.)

Combine two files
User avatar
ckguy
Posts: 465
Joined: Tue Oct 14, 2003 11:20 am
Location: Wakefield, RI, US
Contact:

Post by ckguy »

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.
User avatar
adurdin
Site Founder
Posts: 549
Joined: Fri Aug 29, 2003 11:27 pm
Location: Edinburgh, Scotland
Contact:

Post by adurdin »

levellass wrote:Create a new file (Instead of opening and writing to an existing one)
If it's a text-only file:

Code: Select all

Open "new_file" for output as #1 'or another file number if you've used 1 already
For a binary file:

Code: Select all

Open "new_file" for binary access write as #1
In both cases, replace "new_file" with whatever filename you want.
Read/write input to a specified address in a file. (Instead of having to start from scratch when I open a file for input.)
Use SEEK to seek to a particular byte in a file opened "for binary":

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
The SEEK function in QB counts the first byte of the file as offset 1, while almost everything else counts the first byte as offset 0 -- hence the difference between the address mentioned in the comments and the value passed to SEEK.

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.
Combine two files
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:

Code: Select all

SHELL "copy /b " + filename1$ + " " + filename2$ + " " + outputfilename$
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

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?
You could just say
OPEN "file-that-doesn't-exist" FOR WRITE AS #1
Ah, I though that worked only with existing files, excellent.
User avatar
ckguy
Posts: 465
Joined: Tue Oct 14, 2003 11:20 am
Location: Wakefield, RI, US
Contact:

Post by ckguy »

levellass wrote:So this shell command, does it work in Quick Basic?
It should work ... the SHELL command is used to call any DOS command. Are you having problems with it?
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

I have problems with everything; right now I'm just trying to figure out how I can make Quick Basic do what I want with the commands I have.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Seriously, I'm begginning to doubt this will ever be used; who wants to go to all the troubble of altering sprite behavior? Do you think I should abandon it?
User avatar
Freeyorp101
Posts: 159
Joined: Thu Nov 24, 2005 2:12 am
Location: New Zealand

Post by Freeyorp101 »

^ not really, I think altering sprite properties would be quite useful, and that a program like this would almost certainly be used.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

I don't know, the only patches that are used around here are Andy's, nobody has even used the sprite properties we can alter now, let alone some Basic junket I'm working on.
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

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!
User avatar
Freeyorp101
Posts: 159
Joined: Thu Nov 24, 2005 2:12 am
Location: New Zealand

Post by Freeyorp101 »

When I pushed F5, QB displayed a message saying 'expected : THEN' in a dialog box.
Is this an error or am I missing something?
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Yes; I forgot to add the .BEH files to the download. Moral: Never trust a Levellass link.

It should work *now*
User avatar
CommanderSpleen
Posts: 1017
Joined: Sun Aug 31, 2003 12:11 pm
Location: The Land of Sparkly Things
Contact:

Post by CommanderSpleen »

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.
Post Reply