Loading a client text file into a String array

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()! :sweat:
Instead, declare lines as a global variable outside any functions. :face_with_monocle:

Here’s an online example sketch using drop() instead of createFileInput(): :file_folder:
p5js.ProcessingTogether.com/sp/pad/export/ro.CYTkHWj9smgw8Q

3 Likes

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