sketchPath is not visible (3.0a9)

Hi guys.

I'm playing with the 3.0a versions and have been using 5 for a while and upgraded to 9 after a format. I see quite a lot has changed (awesome!), but am finding some things not working. I hope I did enough research before posting here.

I'm using 'sketchPath' to determine the path of the sketch to open some files in my data folder
String UBUPFile = sketchPath + "/data/UBUP.bin";
Where this has been working fine up until 3.0a5, in a9 it produces the following error
The field PApplet.sketchPath is not visible
There doesn't seem to be anything in the revisions.txt, unless I missed something


  • edited June 2015 Answer ✓

    So they're even spreading private everywhere making our lives much harder! X(
    It's worth a try to use dataPath("") instead though...

  • Answer ✓

    It makes sense to make the sketchPath private because it is set by the Processing core. Being able to change it is likely to cause the sketch to behave oddly.

    Anyway this works in 3.0a9

    String spath = sketchPath() + "/data/UBUP.bin";
    String dpath = dataPath("") + "/UBUP.bin";
  • edited June 2015

    At least we've got at least 4 kinda "getters" for sketchPath:

    • sketchPath("")
    • sketchFile("");
    • dataPath("");
    • dataFile("");

    AFAIK, it is the PDE itself which tells the running sketch where is the sketchPath.
    And I've got a case where it fails: when we override Processing's main().
    Therefore there are times when we need to specify our own sketchPath.
    Again I ask what benefit private brings to us, both answerers & users. :(|)

  • Hi guys

    For reasons you know, given your feedback on the other thread, I will stick with 3.0a5, but have written an empty sketch to just test the 'Path' variants in 3.0a9 so I can 'answer' flag the comments.


  • String spath = sketchPath() + "/data/UBUP.bin";
    String dpath = dataPath("") + "/UBUP.bin";

    A more logical usage is:

    String spath = sketchPath("data/UBUP.bin");
    String dpath = dataPath("UBUP.bin");


  • The incident illustrates the danger of using exposed but undocumented API / fields!

  • Hi PhiLho,

    I've been out of programming for many years and am starting to work on personal projects in Processing. Can you explain the qualitative difference in the syntax between the two sets of assignment statements? I understand both notations, but why is the second usage preferred?

    PS: is this an appropriate place to ask questions, in line like this? or should I post general programming questions exclusively in "How To"?


Sign In or Register to comment.