Why is the compiler objecting to the opening square brackets below? It says "no viable overloaded operator [ ] for type ‘safearray’ " Here is my code. The first two lines appear fine; the problem is with the opening square bracket in the next two lines:
int Y;
Vision2.takeSnapshot(Vision2__SIG_ORANGE);
if (Vision2.objects.[Vision2__SIG_ORANGE].exists){;
Y = Vision2.objects[Vision2__SIG_ORANGE].centerY;
Vision2__SIG_ORANGE is probably a signature and cannot be used as an index into the objects array, you need to use an integer, Vision2.objects.[0].exists etc.
Thanks, that worked for the second line, which is assigning a value to Y. But it didn’t help with the if statement. Can you suggest another way to ask if an object exists?
For anyone following this subject, the following line works for determining if an object exists. So no period before the square bracket, and the integer 1 refers to SIG_1 or whatever you name the first color.
if (Vision2.objects[1].exists) {
Almost, objects is an array of found objects. the “1” simply refers to the second element in the array, which may or may not exist, you need to check objectCount. takeSnapshot is really a filter function. it finds and copies objects that match the filter (either a signature or color code) into the objects array.
Thanks. So i could write:
Vision.takeSnapshot(SIG_1, SIG_2, SIG_3);
and it creates a three element array addressed by 0,1,2 whether or not, say, SIG_1 is found?
and then if(Vision.objects[1].exists is true if a SIG_2 is found, whether or not a SIG_1 is found, right?