-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write global path fetching script for presets modules
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// set-patch-path.js | ||
// | ||
// find the path of the oldest ancestor | ||
// and set a global variable | ||
// | ||
|
||
// dev settings | ||
autowatch = 1; | ||
|
||
/* | ||
////// G L O B A L ////// | ||
////// S E T T I N G S ////// | ||
*/ | ||
|
||
// inlets and outlets | ||
inlets = 1; | ||
outlets = 1; | ||
setinletassist(0, 'find the global path variable (bang)'); | ||
setoutletassist(0, 'global path variable (symbol)'); | ||
|
||
var test = this.patcher; | ||
var testClass = test.parentclass; | ||
var patchPath = ''; | ||
|
||
/* | ||
////// G L O B A L ////// | ||
////// M E T H O D S ////// | ||
*/ | ||
|
||
function bang() { | ||
getParentPatcher(); | ||
getGlobalPath(); | ||
} | ||
|
||
|
||
/* | ||
////// M A I N ////// | ||
////// M E T H O D S ////// | ||
*/ | ||
|
||
// getParentPatcher -- tries to cycle through containing patchers to find oldest ancestor | ||
getParentPatcher.local = 1; | ||
function getParentPatcher() { | ||
test = this.patcher | ||
testClass = test.parentclass; | ||
while (testClass) { | ||
test = test.parentpatcher; | ||
testClass = test.parentclass; | ||
} | ||
} | ||
|
||
// getGlobalPath -- returns path of patcher object | ||
getGlobalPath.local = 1; | ||
function getGlobalPath() { | ||
patchPath = test.filepath; | ||
outlet(0, patchPath); | ||
} |