Hi all -
I’m sure everyone has experienced this problem: folders get moved around, then code falls apart.
I was hoping to program a contingency for missing files that would allow a person to re-assign valid paths to path names that return nil.
I’ve run into a few roadblocks figuring it out, so I thought I’d ask here if anyone has implemented something similar as a quark or shared something along these lines in the past, rather than trying to reinvent the wheel.
Otherwise - here’s the current roadblock… the issue is that it reads all of the storedPaths at once, creating a flurry of dialog boxes when there is a problem. I think the logical thing to do is to increment through the storedPaths and have the ability to check against a new specified folder, if a file is missing… I’m not sure how to do either of these things.
//recalls from an indexed file a series of stored paths.
storedPaths.do{|x|
if (x != nil, {
if (PathName(x[0].asString).isFile, {
//if path is found, do nothing.
},
{ //if path isn't found, open a dialog window, where new folder can be assigned.
{
var win, newPath;
win = Window("", Rect(100, 900, 350, 100)).front;
StaticText(win, Rect(10, 40, 250, 80)).string_(x[0].asString);
StaticText(win, Rect(10, 10, 50, 40)).string_("new path?");
Button(win, (Rect(280, 10, 40, 40)))
.string_("folder")
.action_({|a|
FileDialog.new({|paths| paths[0].postln;},
{ "cancel".postln;})});
TextField(win, Rect(60, 10, 210, 40)).action_({|x|
x.value});
}.defer;
});
});
};
Thanks for the help!