Error console should throw warnings for filesystem functions used before setup() #3433

Closed
JukePlz opened this Issue Jun 26, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@JukePlz

JukePlz commented Jun 26, 2015

The following code works with absolute paths, but not with relative paths even if the file locations are correct:

// Change this line to a relative path and a missing file error prints in console.
PImage myImage = loadImage("C:/mysketch/data/image.png");

void setup()
{
  size(800, 600);
}

void draw()
{
  image(myImage, 0, 0);
}

image.png is any valid png image for processing.

This happens because the environment sets the working directory for the sketch only after setup().
This behavior is probably by design as function usage should only be done in or after setup/draw, but since the error message only pops up for relative directories and is completely misleading I suggest adding an specific warning message for code that executes filesystem access functions before setup, this should make it much easier for beginners to realize why the files are not found, specially when initializing classes in setup that make usage of loadImage themselves.

@benfry

This comment has been minimized.

Show comment
Hide comment
@benfry

benfry Aug 8, 2015

Member

I haven't implemented this in the past because there are potentially a lot of unintended consequences and it's very difficult to explain to users what's going on. But we'll give it a shot for beta 2.

Member

benfry commented Aug 8, 2015

I haven't implemented this in the past because there are potentially a lot of unintended consequences and it's very difficult to explain to users what's going on. But we'll give it a shot for beta 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment