How to solve error message "table cannot be resolved to a variable"

I am a newbie, i searched on StackOverflow and in the Processing Forum before post this question. I also read also the common section questions.

I copied/pasted this sketch from the processing site tutorial : https://processing.org/reference/Table.html

void setup() {

  table = new Table();

  table.addColumn("id");
  table.addColumn("species");
  table.addColumn("name");

  TableRow newRow = table.addRow();
  newRow.setInt("id", table.lastRowIndex());
  newRow.setString("species", "Panthera leo");
  newRow.setString("name", "Lion");

  saveTable(table, "data/new.csv");
}

// Sketch saves the following to a file called "new.csv":
// id,species,name
// 0,Panthera leo,Lion

It gives me the following error message "The variable "Table" does not exist".

Sorry if the question is too stupid! :) Thanks in advance

Answers

  • Is that your complete sketch? You need to declare table somewhere: Table table;. If you're only going to use table in setup() you can add it to line 3: Table table = new Table();

  • I am an idiot, and i am teaching my self to code.
    Thanks @colouredmirrorball for answer me whith your precious time. Now it works :)

  • I am an idiot, and i am teaching my self to code.

    Those two statements are contradictory :P

    My very first post on this forum was about this problem, I would never have figured it out on my own... Three years of practice later and I can spot such issues in a second! So don't hit yourself over it, programming is an art and proficiency only comes with practice.

  • Indeed. Idiots don't learn new things - they believe they already know everything.

Sign In or Register to comment.