AddComponent and query variables from component

I have a Matrix class which is supposed to add Prefabs (Cubes). To the Prefab I added a Script called Quader, in which I defined two variables (qCoordinate & qColor). I now added the Matrix Class to an empty and would like to hand over the Vector3 calculated in the two for loops to the qCoordinate variable in Quader.

Since I cannot Instantiate a Quader calling a Quader new() function I tried to first create a GameObject and then add the variables with AddComponent. But it somehow does not work. Any Help is much appreciated.

    class Quader extends MonoBehaviour
        var qCoordinate:Vector3;
        var qColor:Color;


    class Matrix extends MonoBehaviour
        var mHeight:int;
        var mWidth:int;

    function Start(){

    for(i = 0; i < mHeight; i++){
        for(j = 0; j < mWidth; j++){

            var mQuader:GameObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
            mQuader.transform.position = Vector3(i,j,Random.Range(4,-4));
            mQuader.transform.localScale = Vector3(0.5,0.5,0.5);

You didn't indicate what the error was, but mQuader references a game object, not an object of type Quader, so unless UnityScript does some stuff under the hood that I'm not aware of, you won't be able to access qCoordinate via mQuader.

However, AddComponent() returns a reference to the newly added component, so you should be able to use that instead.