xxxxxxxxxx
48
var test_data
var mx,my
function preload() {
test_data = loadTable("test.csv", "csv", "header");
}
function setup() {
createCanvas(400, 400);
check_table();
print(" find path: ");
// var path = require('test.csv')
// print("path "+path);
// var urlPath = getURLPath();
// print("URLpath "+urlPath);
}
function check_table() {
print(test_data.getRowCount() + ' total rows in table');
print(test_data.getColumnCount() + ' total columns in table');
//print(test_data.getColumn('b'));
//cycle through the table
for (var r = 0; r < test_data.getRowCount(); r++)
for (var c = 0; c < test_data.getColumnCount(); c++) {
print("row " + r + " col " + c + " : " + test_data.getString(r, c));
}
}
function draw() {
background(220);
rect(100, 100, 50, 50);
}
function mousePressed() {
mx = mouseX;
my = mouseY;
print("mousePressed: mx " + mx + " my "+my);
var newRow = test_data.addRow();
newRow.setNum('a', 1);
newRow.setNum('b', mx);
newRow.setNum('c', my);
}
function mouseReleased() {
print("mouseReleased: saveTable ");
//saveTable(test_data, 'test1.csv');
}