[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] error when using .gui method on an Instr



On Dec 21, 2007, at 1:13 PM, felix wrote:

thisProcess.interpretCmdLine could set nowExecutingPath with Document.current.path
and unset it if there is a fatal error.

... and the error printout becomes useless for troubleshooting. I'm not sure we want to make that a general situation.

big complication:
when the code in a file loads other code in other files.
this is really common in Instr and in various players.
there would have to be a messy call stack.

Not messy at all. Just save the old path in the method and restore it at cleanup, like Environment:use does.

executeFile { arg pathName ... args;
var result, saveExecutingPath = thisProcess.nowExecutingPath;
if (File.exists(pathName).not) { ["file \"",pathName,"\" does not exist."].join.postln; ^nil };
thisProcess.nowExecutingPath = pathName;
protect { result = this.compileFile(pathName).valueArray(args) }
{ thisProcess.nowExecutingPath = saveExecutingPath };
^result
}

(That's a change from what I committed before... um, not just "change"... improvement :)

and it has benefits for other code elsewhere

Yes... I'm using it in chucklib so that all the preloaded objects know where they were defined.

hjh


: H. James Harkins

: jamshark70@xxxxxxxxxxxxxxxxx

: http://www.dewdrop-world.net

.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman