We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone. So I'm now entering the world of creating, fetching and parsing data. Very very early stages at the moment and I'm already sweating. My task was to create a table that would save mouseX and mouseY data onto a table of max 10 lines. Pretty simple, pretty straight forward, but it doesn't work. I spent quite a good deal of time trying to understand why, iterating but I keep on getting the same error: "Array index out of range:0" ... Help? Here's the code. Thanks!
Table table;
int counter=0;
void setup() {
size();
table= new Table();
table.addColumn("id", Table.INT);
table.addColumn("valueX", Table.INT);
table.addColumn("valueY", Table.INT);
saveTable(table, "data/new.csv");
}
void draw() {
TableRow row=table.addRow();
row.setInt("id", counter);
row.setInt("valueX", mouseX);
row.setInt("valueY", mouseY);
counter++;
//if (table.getRow()>10) {
// table.removeRow(0);
//}
}
void mousePressed() {
exit();
}
Answers
I think you need to create new rows, actually Tablerow to add your data. See this examplehttps://processing.org/reference/Table.htmlSorry I misread your post.