# Problem Create a Table -

**URL:** <https://discourse.processing.org/t/problem-create-a-table/8586>\
**Category:** Coding Questions\
**Created:** [February 21, 2019, 5:16am UTC](https://discourse.processing.org/t/problem-create-a-table/8586 "2019-02-21T05:16:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ismaiel\_Ahmed](https://avatars.discourse-cdn.com/v4/letter/i/da6949/32.png) [@Ismaiel\_Ahmed](https://discourse.processing.org/u/Ismaiel_Ahmed)\
**Post date:** [February 21, 2019, 5:16am UTC](https://discourse.processing.org/t/problem-create-a-table/8586/1 "2019-02-21T05:16:11Z")

</div>

Hello Geniuses,

I’m trying to save data in a table inside a class

```auto
Table results = new Table();
results.addColumn("Diameter");
results.addColumn("Left Speed");
results.addColumn("Right Speed");

```

When i run the program i always get this message  
`unexpected token: (`  
and it shades this line  
`results.addColumn("Diameter");`

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [February 21, 2019, 5:49am UTC](https://discourse.processing.org/t/problem-create-a-table/8586/2 "2019-02-21T05:49:47Z")

</div>

just to check:  
without any class things… this works:

```auto
Table results = new Table();
results.addColumn("Diameter");
results.addColumn("Left Speed");
results.addColumn("Right Speed");
TableRow newRow = results.addRow();
  newRow.setInt("Diameter", 1);
  newRow.setFloat("Left Speed", 2);
  newRow.setFloat("Right Speed", 3);
saveTable(results, "data/results.csv");
exit();

/* creates dir and file
data/results.csv
content:

Diameter,Left Speed,Right Speed
1,2.0,3.0

*/

```

so might be required that you post little bit more of your code.

ok for a class setup try:

```auto
class MyTable {
  Table results;
  MyTable() {
    this.results = results;
    results = new Table();
    results.addColumn("Diameter");
    results.addColumn("Left Speed");
    results.addColumn("Right Speed");
  }
  void add(int i, float j, float k ) {
    TableRow newRow = results.addRow();
    newRow.setInt("Diameter", i);
    newRow.setFloat("Left Speed", j);
    newRow.setFloat("Right Speed", k);
  }
  void save() {
    saveTable(results, "data/results.csv");
  }
}

MyTable mytable=new MyTable();

void setup() {
  mytable.add(4, 5, 6);
  mytable.save();
  exit();
}

/*
 data/results.csv
 content:
 
 Diameter,Left Speed,Right Speed
 4,5.0,6.0
 
 
 */

```

---

<div class="post-metadata">

**Author:** ![Ismaiel\_Ahmed](https://avatars.discourse-cdn.com/v4/letter/i/da6949/32.png) [@Ismaiel\_Ahmed](https://discourse.processing.org/u/Ismaiel_Ahmed)\
**Post date:** [February 21, 2019, 3:29pm UTC](https://discourse.processing.org/t/problem-create-a-table/8586/3 "2019-02-21T15:29:18Z")

</div>

Thanks … That’s all my code

```auto

class Robot {
  float diameter;
  float distance;
  int index = 1; //index for number of outputs
  int condition; //if (Nl == Nr or Nl = -Nr) = 0; 
  
  float [] velocityLeft = {1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0, -0.1, -0.2, -0.3, -0.4, -0.5, -0.6, -0.7, -0.8, -0.9, -1.0};
  float [] velocityRight = {1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0, -0.1, -0.2, -0.3, -0.4, -0.5, -0.6, -0.7, -0.8, -0.9, -1.0};
  
  Table results = new Table();
  results.addColumn("Diameter");
  results.addColumn("Left Speed");
  results.addColumn("Right Speed");
  
  float Nl; //Right wheel velocity
  float Nr; //Left wheel velocity
  float theta = radians(0); //Angle with -x-axis
  
  float firstLocationX;
  float firstLocationY;

  float radius = 3; //DDMR wheel radius
  float L = 6; //Distance between two wheels
  
  float vx;
  float vy;
  PVector velocity = new PVector(vx, vy); //linear velocity
  PVector location; //DDMR current location
  float omega; //Angular velocity
  
  float initialX;
  float initialY;
  
  Robot (){
    initialX = 300;
    initialY = 300;
    location = new PVector (initialX, initialY); // Initialize the location.
  }
  
  void display(){
    
    for (int iterationLeft = 0; iterationLeft < velocityLeft.length; iterationLeft ++)
    {
      for (int iterationRight = 0; iterationRight < velocityRight.length; iterationRight ++)
      {
       
        TableRow newRow = results.addRow();
        condition = 1;
        diameter = 0;
        distance = 0;
        
        Nl = velocityLeft[iterationLeft];
        Nr = velocityRight[iterationRight];
        omega = radians((radius/(2*L))*(Nl-Nr));
        
        firstLocationX = location.x;
        firstLocationY = location.y;
        
      
        
        if (Nl == Nr) 
          {
            newRow.setFloat("Diameter", 99999);
            newRow.setFloat("Left Speed", Nl);
            newRow.setFloat("Right Speed", Nr);
            
            condition = 0;
            
            index ++;
          } else if (Nl + Nr == 0) 
          {
            newRow.setFloat("Diameter", 0);
            newRow.setFloat("Left Speed", Nl);
            newRow.setFloat("Right Speed", Nr);
            
            condition = 0;
           
            index ++;
          } 
          
          

        while (condition == 1) 
        {
            
            //new location
            location.add(velocity);
            //Calculate velocity 
            velocity.x = (radius/2)*cos(theta)*(Nr + Nl);
            velocity.y = (radius/2)*sin(theta)*(Nr + Nl);
            //new angle
            theta = theta + omega;
          
            
            
            distance = dist(firstLocationX, firstLocationY, location.x, location.y);
            print("Diameter = " + diameter + " -- " + "Distance = " + distance + "\n");
            
            if (diameter < distance)
              {
                diameter = distance;
              }//end of (if) statement 
            
            if (diameter > distance)  
              {
                newRow.setFloat("Diameter", diameter);
                newRow.setFloat("Left Speed", Nl);
                newRow.setFloat("Right Speed", Nr);
                saveTable(results, "data/new.csv");
                //print(index + " : Diameter= " + diameter + " - Left Speed = " + Nl + " - Right Speed = " + Nr + "\n");
                condition = 0;
                index++;
                velocity.x = 0;
                velocity.y = 0;
              }//end of (if) Statement 
            
        }//end of (While) Loop 
        
     
      }//end (for) iterationRight loop
    }//end (for) iterationLeft loop  
    
  }//end void Display()
    
}//end class Robot

```
