Posted: 15th Jun 2007 11:14
I'm getting this error when i wanted to delete all objects i've loaded.
Here's the code:

+ Code Snippet
for count=1 to 10000
     if object exist(count) then delete object count
     if image exist(count) then delete image count
next count


What is this?

Thanks..
Posted: 15th Jun 2007 11:32
Object number Illegal means you've tried to delete/check/move whatever an object with the number 0, the code you've posted is fine so the error must be elsewhere.
Posted: 15th Jun 2007 11:55
Thanks dark coder.
But it highlights that line;
+ Code Snippet
     if object exist(count) then delete object count
Posted: 15th Jun 2007 12:15
As for deleting the objects, have you tried "DELETE OBJECTS 1,10000" instead? That's much faster and you can get rid of all objects with a single command.

Oh, i didn't know that thanks a lot.
Posted: 15th Jun 2007 22:46
but to answer your question its becuase of this:
+ Code Snippet
for count=1 to 10000
     if object exist(count) then delete object count
     if image exist(count) then delete image count
next count


instead of

+ Code Snippet
for count=1 to 10000
     if object exist(count) = 1 then delete object count
     if image exist(count) = 1 then delete image count
next count


that would be my guess
Posted: 15th Jun 2007 23:15
for count=1 to 10000
if object exist(count) = 1 then delete object count
if image exist(count) = 1 then delete image count
next count



that would be my guess


No, his code is valid. 'If Variable' will execute the statement as long as Variable isn't 0.
Posted: 15th Jun 2007 23:59
Yeah there's no problem with if statement...
Posted: 16th Jun 2007 1:02
wow thats crazy i never knew that... so your saying that

+ Code Snippet
if mousclick() then gosub fire

is the same as
+ Code Snippet
if mouseclick() = 1 then gosub fire


??
Posted: 16th Jun 2007 1:10
Yes, the equals sign is an operator, just like the plus sign is. It takes what is on the left, compares it with what is on the right, and gives a result of 0 if they differ, or 1 if they are the same value.

The IF command will take the 'true' path if the value is non-zero, and the 'false' path if the value is zero. WHILE...ENDWHILE and REPEAT...UNTIL operate in the same way.

Here's a simple example showing that '=' is 'just another operator':
+ Code Snippet
a = 10
for i = 1 to 20
   print i; " - "; a = i
next
wait key
Posted: 16th Jun 2007 4:45
Suicidal Sledder:

It's called an 'implied condition'. If you don't use a boolean operator like =, <, >, or <> which tests for a True or False result then testing for a True result is 'implied' (assumed).

TDK_Man
Posted: 16th Jun 2007 11:13
Also, the implied condition is only not false, which includes anything that is not zero. True, by definition is really only 1, but anything that is not 0 evaluates to true. In the case of mouseclick, it is not a boolean, and coding like the first snippet is quite buggy, to say the least.

I have more trouble with using if/then...it is asking for logic errors, imo, and you usually wind up needing a block anyway. Same goes for using the ':'.

Also, I have seen the implied condition fail, especially when you try to evaluate multiple conditions. I have found that if you make it completely obvious to the compiler, it makes the correct code. That is why I don't use the shortcut logic in DBPro. In C/C++, it causes subtle side-effects that usually are very difficult to track down and eradicate.
Posted: 16th Jun 2007 20:48
And after all that we still don't know why bandM is getting the error.

I favour dark coder's answer - the error messages don't always point at the correct line.

It's just possible there is an invisible character in the line. Have you tried pasting those lines into a file of their own and running it? What happens then? It should just compile and run.
Posted: 16th Jun 2007 21:30
And after all that we still don't know why bandM is getting the error.

Yes.
But it's gone!!I did no change,nothing and it's gone when i recompiled whole project.