Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [dbp] Delete function

Author
Message
Stefan p
15
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 10th Jan 2009 20:36 Edited at: 17th Jan 2009 01:58


Feel free to use or add on to it.
Edit: updated
Edit: updated

I was here.
AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 10th Jan 2009 20:53
Cool. However I noticed a couple things:

a) It only deletes music, sounds, images and sprites. It should also delete matrices, objects, vectors, memblocks, cameras, particles, and it should close files.
b) It can only delete one type of thing at a time. Try implementing some kind of parsing so the parameter could be "sprites, images, sounds" and it would delete all three of those things.
c) Change 'wat$' to 'lower$( wat$ )', that way the parameter could be 'Sprites' or 'IMAGES' and it would still compare it properly.
d) The function assumes that you only have a max of 99 things. Make a parameter that lets the user choose the number of objects he has with a parameter, then loop until that number. That way if someone has 10 objects the loop only has to iterate 10 times, and if they have 5000 then they won't be constrained to a 99-iteration loop.
e) You should probably put an 'ExitFunction' at the end of each sub-routine.


Stefan p
15
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 10th Jan 2009 22:13
I did e) , d) ,but need help with c) cause it wont work for me. this is it right


I was here.
Mr Kohlenstoff
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 10th Jan 2009 23:41
I think you should do it this way:



Further you might think about using constants instead of a string to define what should be deleted..



You could also use a select-case-block instead of subroutines within the function, which is probably faster and also better to read.
However, I'm wondering why you wrote "inc a,1" into every for-next-loop.. looks like it would only delete every second image/sprite/object/whatever?

Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 11th Jan 2009 20:43
I don't really get the parts



You reset the a to 1, but the for does this automatically, so there's no need for that line.
Seconly, the for loop also increases a automatically by 1 when it reaches next, so if you use the line inc a,1, you actually increase a by 2.
Like in this program:


It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.

Login to post a reply

Server time is: 2024-05-18 18:03:57
Your offset time is: 2024-05-18 18:03:57