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.

Newcomers DBPro Corner / for and next problem

Author
Message
the destroyer
15
Years of Service
User Offline
Joined: 24th Dec 2008
Location:
Posted: 30th Jan 2009 21:02
Hello my problem is that when I use the for next loop a message appear telling me that the object is not found
here is my code

thanks
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 30th Jan 2009 21:15
The problem is with the line 'set object collision on o'.

The variable 'o' is outside of the for/next loop - at this point, having gone through the loop, the variable contains the value '16'. You don't have an object 16.

Perhaps you meant to put that command inside the loop?

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 30th Jan 2009 21:17 Edited at: 30th Jan 2009 21:17
the last thing your for/next loop does is increment o which makes it = 16. you don't have an object 16, so...

put this line inside the for/next loop to remedy:

set object collision on o

edit: heh. what he said

Virtual Nomad @ California, USA
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit
Dabbler
17
Years of Service
User Offline
Joined: 3rd Mar 2007
Location: Minnesota
Posted: 30th Jan 2009 21:40
You will have the same problem with this line:



You may have ment to use zero instead of 'o'.


Whatever...
pollywog
17
Years of Service
User Offline
Joined: 18th Jan 2007
Location:
Posted: 30th Jan 2009 21:58
odd that o doesn't go out of scope.
in most languages after you left the loop o would be meaningless. since it was declared in the loop.

so I thought that once you left the loop o would be 0
but apparently reading your post it is set to whatever the last iteration of the loop was.

that's a nasty little tidbit I better remember or I'm sure it will come back to bite me. since I'm a big fan of while loops if I attempt to use the same variable name again without resetting It would be trouble.

Login to post a reply

Server time is: 2024-09-28 02:27:24
Your offset time is: 2024-09-28 02:27:24