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.

DarkBASIC Discussion / Runtime Error?

Author
Message
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 23rd Jan 2008 18:14 Edited at: 25th Jan 2008 15:29
When you go to the store, it deletes everything in play and loads new sprites,objects,etc. for the store, but when I exit the store to tend back to my dog, I get a runtime error saying the sprite doesn't exist. I have to put almost all of my source but here it is,

[source deleted]

Thanks,
Jordan


Formerely Cool Guy Jordan
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 23rd Jan 2008 20:10
Your lack of proper indentation doesn't help either. How many times have we told you to indent your code properly?

TDK_Man

Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 24th Jan 2008 00:37 Edited at: 24th Jan 2008 00:39
This was before you told me that... But I tried what WindowsKiller told me and it didn't work. And the program picks up where you left off when you exit the store. So anyway to make it work?


Formerely Cool Guy Jordan
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Jan 2008 02:03
Quote: "This was before you told me that."


So do you mean that as you started writing it before you were told to sort out the indentation you aren't going to bother?

The thing is, your code is messy - as WindowsKiller correctly points out.

It's lack of indentation makes it very hard to follow and therefore many times harder to read and locate problems. If you want other people to help you, you should be trying to make it as easy for them to do so as possible.

In fact, if you indent it properly, you may well spot a lot of the problems yourself.

Personally, (I can't speak for anyone else), if you aren't inclined to bother sorting your code out, I'm not inclined to spend time and considerable effort trying to find the problems with it.

I'm sure it's not the case, but you are coming across as the 'fix this for me as I can't be bothered' sort.

TDK_Man

Cash Curtis II
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 24th Jan 2008 12:56
Worse than the bad indentation is the fact that you're using Gosubs without Returns Jordon Stories Games. You'll cause a memory leak because you're never emptying the stack and eventually crash your program. That way you're using them they are just Goto statements, and that is generally a bad way to program.

Also JSG you shouldn't be deleting resources like you are. You need to manage them better.


Come see the WIP!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Jan 2008 18:21 Edited at: 24th Jan 2008 18:23
Quote: "Worse than the bad indentation is the fact that you're using Gosubs without Returns"


100% agree with you Cash.

The only reason I didn't mention that again (WK pointed it out also) was because after proper indentation, problems like that stick out like a sore thumb and I wanted him to at least try to solve some of his own basic problems instead of posting here at the first sign of trouble...

He's been using DB since mid-2006 and still doesn't know all procedures must have Returns?

It's a 'cruel to be kind' sort of thing!

TDK_Man

Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 24th Jan 2008 21:43
I thought if you had a loop, it didn't have to have return. Plus I didn't use return because that subroutine will go in to the next subroutine... I wasn't here to be bashed by my coding style, I was here to get a answer for my problem.


Formerely Cool Guy Jordan
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Jan 2008 22:48
Quote: "I wasn't here to be bashed by my coding style, I was here to get a answer for my problem"


But what if your problem is being caused by your coding style?

That's what we are trying to get through to you...

Quote: "Plus I didn't use return because that subroutine will go in to the next subroutine"


Which only goes to show that you haven't got a grasp of the most elementary aspects of procedural programming.

If you ignore the advice from people who know what they are talking about then those people aren't going to bother helping you at all next time you are stuck. Your loss really...

TDK_Man

Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Jan 2008 03:31
@JSG
Sorry I have to agree with TDK on this one.
Your subroutines should come after your main loop, then they are all nicely filed away and you can use them without clogging up your main program, like this


Your program looks very similar to my first big programs, the problem I had with subroutines is I was thinking of them like pages of a book, jumping from one to the next.

have a look at my program structure tutorial
http://forum.thegamecreators.com/?m=forum_view&t=111855&b=10

@TDK
I would like your feedback on my tutorial as yours have been so successful.

Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 25th Jan 2008 15:09
Thanks, but what about the other problem? BTW, I am reading the tutorial.


Formerely Cool Guy Jordan
Cash Curtis II
20
Years of Service
User Offline
Joined: 8th Apr 2005
Location: Corpus Christi Texas
Posted: 28th Jan 2008 08:07
@Zeus -
I help lots of people with their code. I'm quite good at tracking down bugs. However, if you can't grasp the basics and refuse to listen to anyone else then you just won't get helped. The way you're coding your game will cause serious problems for you. It would be like if you had a function declaration in the middle of your loop. The difference, of course, is that the compiler can't catch your error.

To expand on what OBese87 said, your subroutines can be used like functions in your main loop...



Come see the WIP!
Libervurto
18
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Jan 2008 11:16
@Zeus
How Cash uses subroutines is very useful, it means you can use the same code over and over without having to rewrite it.

The tricky thing is knowing when to use a subroutine and when to use a function.
I think of subroutines like books, you can use them when you need to but you can never change their contents. Functions are more like blenders: you chuck a load of stuff in and it processes it all and chucks out the end result.
PS Don't put books in blenders

Login to post a reply

Server time is: 2025-06-05 19:15:14
Your offset time is: 2025-06-05 19:15:14