ObjectFind always true.

 

I've been away a while.. lots changed!

But today I'm getting ObjectFind return "true" when there is no object with that name...

void OnStart() {
   if(ObjectFind(0,"456")) Alert("found: 456");
   else Alert("not found: 456");
   return;
}

 You get the same? 

 
Read the documentation - ObjectFind is not a boolean function, it returns a negative number if it doesn't exist and anything other than 0 equates to true.
 
GumRai:
Read the documentation - ObjectFind is not a boolean function, it returns a negative number if it doesn't exist and anything other than 0 equates to true.

0 means that the object has been found in the main window of the chart

it returns an integer of less than 0 if not found

 
GumRai:
Read the documentation - ObjectFind is not a boolean function, it returns a negative number if it doesn't exist and anything other than 0 equates to true.
rod178:

0 means that the object has been found in the main window of the chart

it returns an integer of less than 0 if not found

I didn't word that very well did I  :)

 ObjectFind is not a boolean function

If the object is not found, the function returns a negative number

As the object does not exist a negative number is returned

As Alladir is testing a number as a boolean ,and anything other than 0 equates to true, Alladir's code will return true if the object does not exist.

If it does exist and is in the main window, Alladir would have found it return false, because the main window is expressed as 0 

 
GumRai:

I didn't word that very well did I  :)

 ObjectFind is not a boolean function

If the object is not found, the function returns a negative number

As the object does not exist a negative number is returned

As Alladir is testing a number as a boolean ,and anything other than 0 equates to true, Alladir's code will return true if the object does not exist.

If it does exist and is in the main window, Alladir would have found it return false, because the main window is expressed as 0 

LOL I knew what you meant, although only because I'm familiar with that function  :P