Query Vertex Color

I am having a dificult time understanding the data types used when trying to query the color of a vertex. what kind of data is returned and how do you use it?

I am writing this littel script that querys a mesh loooking for a vertex in which the green attribute is equal to one.

The error I get is

// Error: Cannot use data of type float[] in a scalar operation. //

How do I convert the output into something that will work. I can't believe that I have never had to convert data types in mel before so i'm a bit lost. Thanks for any help you can give.

CODE
        string $intSelection[] = ls -sl -fl;        
        polyColorPerVertex -g 1;
        polySelectConstraint -m 3;
        string $revSelection[] = ls -sl -fl;
//        print $revSelection[0];
//        print $revSelection[1];
//        print $revSelection[2];
//        print $revSelection[3];

        select -cl;
        //path to file
        $filename = ("C:/2dTrussLoads.txt");

        int $i;

    //    float $colorQuery;

        // open the file for writing
        $file = fopen $filename "w";
        global float $neigh1;
        global float $neigh2;
        // fprint
        fprint $file ( "Nodal Loads" + "\n" );

        while($i < size($revSelection)){
        select -r $revSelection[$i];
        //$colorQuery[0] = `polyColorPerVertex -q -g`;
        if(`polyColorPerVertex -q -g` == 1){
        fprint $file ( $neigh1 + "\n" );
        fprint $file ( $neigh2 + "\n" );
        }

        if(polyColorPerVertex -q -g == 0){
        fprint $file ( "0" + "\n" );
        fprint $file ( "0" + "\n" );        
        }

        $i = $i + 1;
    }
        // close file
        fclose $file;
}

getAttr and most other mel commands deals with arrays (mel is a language that acts on arrays), in fact maya internally represents stuff as compounds and they arent of mel understandable type.

now (polyColorPerVertex -q -g == 1) its like asking is a passanger plane equal to a dog.

Now polyColorPerVertex -q -g returns a array of a value for each selected vertex or vertexface. As such ist probably better taht you not rely on this mechanism but rtaher explicitly pass the polyColorPerVertex a querry set. but fine.

It does not even matter if you just querry one value, its still a array with size 1. Now its not very good idea to ask for the value of eactlly 1, because if its painted in its realy realy RARE indeed

CODE
{
for ($item in ls -sl -fl){
$color=polyColorPerVertex -q -g $item;
   if( $color[0]> 0.9){
     print ( "yes\n" );
   }else{
     print "no\n";
   }
}
}

Tough if you ask the whole mesh you should realy do:

CODE
{
for ($item in polyColorPerVertex -q -g){
   if( $item> 0.9){
     print ( "yes\n" );
   }else{
     print "no\n";
   }
}
}

its faster, MUCH faster, also you should do writes in chunks a small wirte like that can be a bit slowing even if its cached.