var line = "";
function setup() {
createCanvas(100,100);
background(240);
jQuery.get('positions.txt', function(data) {
line = data;
});
}
function draw() {
try {
//line = reader.readLine();
//console.log(line);
var pieces = line.split(',');
} catch (e) {
console.log("The error is ", e);
line = null;
}
if (line == null) {
// Stop reading because of an error or file is empty
noLoop();
} else {
//var pieces = line.split(','); // was » String[] pieces = split(line, TAB);
for (var i = 0; i < pieces.length; i++){
var pointPos = pieces[i].split('t'); // was » var x = pieces[0]; var y = pieces[1];
point(pointPos[0],pointPos[1]); // was » point(x, y);
}
}
}
The code works, as in I get the expected visual display. But the try/catch part is not behaving as I think it should