We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I try to catch the sketchpath in the settings() but i cannot use the sketchPath() method. I try few stuff but it's too much hard for me. bellow my try !
void settings() {
String folder = null ;
String jarPath = PApplet.class.getProtectionDomain().getCodeSource().getLocation().getPath();
if (jarPath.contains("Contents/Java/")) {
String appPath = jarPath.substring(0, jarPath.indexOf(".app") + 4);
File containingFolder = new File(appPath).getParentFile();
folder = containingFolder.getAbsolutePath();
}
println(jarPath) ;
println(folder) ;
File currentDirectory = new File(new File(".").getAbsolutePath());
println(currentDirectory) ;
println(currentDirectory.getAbsolutePath()) ;
}
void setup() {
println(sketchPath()) ;
}
Answers
Well, I've told ya in your previous thread that the source code itself needs fix: :-@
http://forum.processing.org/two/discussion/12568/choice-where-to-display-the-fullscreen-from-external-file
Processing 3, besides bringing lotsa bugs and not any worthy feature, has arrogantly decided to lock everything up so we can't fix the library by ourselves either! X(
Contrary to what we would expected from sketchPath(), it can't find out sketch's path whatsoever!
Actually it is Processing's IDE (PDE) which passes it to the running sketch via "--sketch-path=" arg! (:|
Problem is that sketchPath variable (which is now
private
to make matters worse), only receives "--sketch-path=" just after settings() call is finished! @-)In short, when code is inside settings(), it is oblivious to the "true" sketch's path! 3:-O
Most we can do is export the sketch via CTRL + SHIFT + E.
In which case sketchPath(), dataPath(), sketchFile() & dataFile() finally work inside settings(): :-\"
Like I say that's don't work ... maybe only on OSX :(
Have you exported the application and double-clicked on it to run it? :-/
It works in Windows both by double-clicking it and from the console. :(|)
Oops, that's work. Sorry, i'm not conforatable with english, I haven't understand that I must creata an app to check. Thank you very very much. Now, I Must work around that, to create a path for my project !
If I understand is not possible to find the path in the settings() except with the export app. If I want find the path with the sketch I write a method with JAVA ?
Again, I've already answered that in your previous post:
http://forum.processing.org/two/discussion/12568/choice-where-to-display-the-fullscreen-from-external-file
That's why it's very bad opening new forum threads for the same subject! Creates fragmentation! :-@
Class PApplet itself needs to be fixed in order for sketchPath (and others like args[]) to be correctly initialized w/ the actual running code's path inside settings()! [-(
You can ask "them" to make that needed correction here:
https://GitHub.com/processing/processing/issues
But watch out: They don't like such "implementation detail" requests and they "bite" hard! >:)