Skip to content

Commit

Permalink
Write global path fetching script for presets modules
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Sep 21, 2015
1 parent d02b533 commit 46b7be4
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions javascript/set-patch-path.js
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);
}

0 comments on commit 46b7be4

Please sign in to comment.