We are about to switch to a new forum software. Until then we have removed the registration on this forum.
selectInput("Select a file : ","fileSelected"); defaults to my Documents folder but not to my Processing folder, which is on Dropbox. Is there a way to have selectInput() select files in the sketchbook folder:data folder?
Answers
From selectInput()'s reference example, using its overloaded version w/ 3 parameters + dataFile():
https://Processing.org/reference/selectInput_.html
This gets me almost there. I can manually enter the file path all the way to the file inside the current MyApp.pde/data folder but that changes with each revision. If I can find the variable that holds the current running filename of the MyApp.pde, I'm home free.
"current running filename"? What do you mean by that? :-/
I found it in another post. Life is good!
// forum.processing.org/two/discussion/12572/sketchpath-in-the-settings // 2015-Sep-18
String AppSketchPath, AppDataPath;
void settings() { size(800, 200, JAVA2D); noLoop(); AppSketchPath = sketchPath(); AppDataPath = dataPath(""); }
void setup() { getSurface().setTitle(AppDataPath); String[] paths = { AppSketchPath, AppDataPath }; saveStrings(AppDataPath + "/Paths.txt", paths); }
The full pathname of the currently running sketch.
https://forum.Processing.org/two/discussion/15473/readme-how-to-format-code-and-text
You've asked for "running filename", not "running pathname". But whatever... :-\"
Besides those 2 you've found out, there are also their corresponding versions which returns a File object instead of a String one:
As you can see, in my posted example, I've used dataFile() as selectInput()'s 3rd argument. >-)
Thank you!