I’m a bit new to js. I’m not sure how to load a file. The following code does not work.
input2 = createFileInput(handleFile2);
input2.position(width/2, height/2);
function handleFile2(file)
{
var lines = loadStrings(file);
}
I’m a bit new to js. I’m not sure how to load a file. The following code does not work.
input2 = createFileInput(handleFile2);
input2.position(width/2, height/2);
function handleFile2(file)
{
var lines = loadStrings(file);
}
lines is being declared as a local variable to function handleFile2()!
Instead, declare lines as a global variable outside any functions.
Here’s an online example sketch using drop() instead of createFileInput():
p5js.ProcessingTogether.com/sp/pad/export/ro.CYTkHWj9smgw8Q
Sorry, GoToLoop. I didn’t include the whole sketch. Those are just code fragments. I just found the answer to my question in this video from Shiffman: Getting Text from User: Loading a Text File - Programming with Text
Thanks for the response