Bug 713 : loadString bug
Last modified: 2008-02-17 15:52



Assigned To:

Attachment Type Created Size Actions

Description:   Opened: 2008-01-15 20:50
On 0135 BETA

It looks like if you use loadStrings() more than once in a class like
loadStrings(myfile) it will complain that it cannot find the second file.
Even if you call the same file twice. But simply changing the loadStrings()
in the second method to the full path for the file like
everything works again.

Also relative paths do not seem to work.
Additional Comment #1 From fry 2008-01-15 21:00
please provide an example sketch (use tools > archive sketch, and attach it
to this bug report) loadStrings() gets used heavily so i'd be quite
surprised if it was breaking in the fashion you describe.
Additional Comment #2 From Dimitre 2008-02-17 15:40
I have a similar issue with loadStrings()
my file is on data folder with the right permissions, so I tried to reduce the code to get the
situation where it works and it doesn't

this code works perfectly
String lines[] = loadStrings("geena.txt");

and this doesn't
String lines[] = loadStrings();

void setup() {

and with absolute path it works again
String lines[] = loadStrings("/Users/dimitre/Documents/Processing/geena/data/geena.txt");

void setup() {

both void setup and draw trigger this
Additional Comment #3 From Dimitre 2008-02-17 15:44
correcting, this is the code that doesnt work

String lines[] = loadStrings("geena.txt");

void setup() {

it returns as file missing or inacessible

OS X 10.5.2, Processing 135 here
Additional Comment #4 From fry 2008-02-17 15:52
no, that's a bug in your code.

you cannot use loadStrings() before setup() has run, because the sketch
will not be initialized properly. it may work with an absolute path before
setup() runs because may not need to be initialized in that case.

in code that does not have setup() or draw() methods at all, the
preprocessor places all of that code inside a single setup() block, which
is why it may be confusing that it works when setup() and draw() are not