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 / Compilation Successful - Sounds good but it's not....

Author
Message
No Time To Code
15
Years of Service
User Offline
Joined: 22nd Dec 2008
Location:
Posted: 9th Jan 2009 04:53
I'm working on this Pacman program and I have it at the point where the Ghost come out of the pen and move around the maze. I don't have any ghost/pacman collision yet so they should just move around indefinitely. Instead, whether it's 30 seconds or 2 minutes into the program, it exits back to DBEdit with the message "Compilation Successful". No error message or explanation on why it exited. Any thoughts on why that would be?
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 9th Jan 2009 07:50 Edited at: 9th Jan 2009 08:46
Have you narrowed down which function/routine is causing the problem? If not, try removing all function calls from your main loop (via REM) and then 1 by 1 add them back.

If you have, I would suggest taking the function itself into a new file and just experiment with the code, adding in WAIT KEY commands periodically to see what it is that causes it.

If I have time tomorrow after class I will check it out myself, but till then, those are my suggestions.

[EDIT]
Tried to compile it, got a file not found. Try unlocking the CLI and seeing what happens

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 9th Jan 2009 15:49
BN2's right. The LOCK CLI command will cause the editor to skip out on any error reporting and return to windows.

One error, off the bat, is a nesting error. You have an EndWhile without a While in your New_Round: subroutine

Enjoy your day.
Caleb1994
15
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 9th Jan 2009 21:46
yall beat me to it haha
No Time To Code
15
Years of Service
User Offline
Joined: 22nd Dec 2008
Location:
Posted: 10th Jan 2009 02:21
Quote: "One error, off the bat, is a nesting error. You have an EndWhile without a While in your New_Round: subroutine
"

I did have a WHILE but my code wasn't indented so I guess it was hard to see, Here is that sub with indentation:



Quote: "BN2's right. The LOCK CLI command will cause the editor to skip out on any error reporting and return to windows."

Latch - I was using the LOCK CLI as per your response to my post about the screen sometimes going haywire upon exit with ESC. Thus far it was worked great and I haven't had that problem. I will remove it and see if I get a better explaintion of the error.
No Time To Code
15
Years of Service
User Offline
Joined: 22nd Dec 2008
Location:
Posted: 10th Jan 2009 02:52
I removed the LOCK CLI and the error is "Runtime error at line 280. Array accessed out of bounds at line 280". This is line 280:

This array is DIMed as follows:

The value of G should never be more than 4 because it's based on a FOR NEXT LOOP

I added these line to try to catch the value of G before the error:

but I got the same runtime error and since I never saw the text "error G = "???, I assume G was never > 4.

Is there a better way to catch the value of G before the error or does this "Array out of bounds" mean something else?
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Jan 2009 04:01
The error could be due to
ghost_dir(G,1) = Holdchoices(Rnd(ctr)+1)
because rnd(ctr)+1 could = 6 and Holdchoices() is dimensioned to 4.


Quote: "I did have a WHILE but my code wasn't indented so I guess it was hard to see"

Yikes! It was completely my fault because I had removed the while because it was referencing a sound and I was getting an error! OOOPS!

Quote: "Thus far it was worked great and I haven't had that problem. I will remove it and see if I get a better explaintion of the error."

Maybe all of your code had been perfect until now... Wouldn't that be a dream? Actually, it might only flag on certain errors because the following erroneous code causes no exception with lock cli:


While this does:



That's why I said as an undocmented command, it could be risky... but I guess it's still better than the crashing alternative!

Enjoy your day.
No Time To Code
15
Years of Service
User Offline
Joined: 22nd Dec 2008
Location:
Posted: 10th Jan 2009 04:31
Quote: "The error could be due to
ghost_dir(G,1) = Holdchoices(Rnd(ctr)+1)
because rnd(ctr)+1 could = 6 and Holdchoices() is dimensioned to 4.
"

THAT WAS IT!! Thanks Latch!
I think the most it could have been was 5 because ctr=1 and the most it could be inc by in the loop was 4

But to your point, I had Holdchoices() DIMed as 4
I was so focused on the ghost_dir array I didn't even think to look at the Holdchoices array.

Thank heavens for folks like you, BN2 and others to help noobs like me!

Quote: "Maybe all of your code had been perfect until now... "
Yeah, I would be dreaming but I learn something from every error.

LOCK CLI has been good to me so far so I'll stick with it until I get another "Compilation Complete" message.

Thanks again to all who helped. I will finish this game!!!
Latch
17
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Jan 2009 05:25
Be careful with your logic

starts out as 1. A loops up to 4 and ctr is incremented so it could be 5. Then Rnd(ctr)+1 add 1 to a possible ctr of 5 so it could be 6



Enjoy your day.
No Time To Code
15
Years of Service
User Offline
Joined: 22nd Dec 2008
Location:
Posted: 10th Jan 2009 05:51 Edited at: 10th Jan 2009 05:54
Your right. Since there can only be a maximum of four directions to move (4 way intersection) should I rewrite like this

This most the ctr can be is 4 and the result of Rnd(ctr-1)+1) should be a number between 1 - 4. If ctr is 1 the result of Rnd(ctr-1)+1) should be 1.(The Rnd number would have to be 0 then add 1 - I think? ). Anyway I think ctr should always be at least 2 since the ghost should always have at least two choices of direction.

Login to post a reply

Server time is: 2024-05-03 17:04:01
Your offset time is: 2024-05-03 17:04:01