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 / Odd freezing problem

Author
Message
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 22nd Aug 2008 23:41 Edited at: 22nd Aug 2008 23:42
For some reason, when I run these three functions, it freezes up on me, randomly. The odd thing is, I have identified where it freezes, but it shouldn't be doing it. It happens in the hbox function, when the first set of for next loops completes, however it will not go past next s at all. I put in code to put s and v on the screen as well as the start and end values of each, showing that it only happens as soon as it completes. Oddly enough, even the CLI doesn't open when it freezes, making me thing maybe there is some sort of a glitch (or incompatibility with vista)

I tried to explain it as best as I can, but with my luck none of you will be able to make it happen, so here are the three functions:


This requires a few arrays to be created, here they are
map(40,40)
map2(40,40)
gmap(1) (set this to 1)

gmap is being used as a global constant, rather than re-writing all my functions and their calls to accept an extra parameter.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?
NanoGamez guy
19
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 23rd Aug 2008 13:01 Edited at: 23rd Aug 2008 13:05
1. What does this thing do? I made it draw out the array on the screen and all it seemed to be doing was very inefficiantly filling an array.

2. Why on earth have you got a function that calls itself? That makes it so hard to debug.

3. I think I found the problem. In the code:

As you know a for loop loops until a variable reaches a certain value. However what your doing doing with this code:

is stoping it from reaching that value. So the for loop keeps going forever and freezes the program. What you need to do is change the value that the for loop loops until so that it is always below or equal to 40. e.g.




On the other hand, you have different fingers.
BN2 Productions
22
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 23rd Aug 2008 13:04
Thanks nano, that worked!

Quote: "Why on earth have you got a function that calls itself? That makes it so hard to debug.
"

Quite true, I got the algorithm from a website. It is a (tweeked) flood fill algorithm. I am sure there is a much better way to do it, but that one works.

Quote: "1. What does this thing do? I made it draw out the array on the screen and all it seemed to be doing was very inefficiantly filling an array."

Part of my challenge entry. I know it is terrible and won't stand up against others, but it (sort of) works.

Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?

Login to post a reply

Server time is: 2026-07-05 13:38:42
Your offset time is: 2026-07-05 13:38:42