Hello,
I am looking to call efsInternal() multiple times, with different input vars, but each require having their own set of "global vars". My idea was to create an array that gets passed in, it does some work on the values of that array, then passes the array back with the updated vars. These arrays would be stored at the main's global scope.
The fact that I am calling efsInternal() multiple times, using different input vars means I can't use normal global vars (I'm assuming), so I have to come up with some way to have each one keep track of its own state.
I have two questions. One, is this the way I should approach this to begin with? Two, what is the best way to do this performance-wise (is there a way to call efsInternal() once in an Init instead of each bar? Is calling getSeries() each time very slow? etc.) ?
(I'm not sure if the following is syntactically correct)
Any help is greatly appreciated! Thanks!
Daniel
I am looking to call efsInternal() multiple times, with different input vars, but each require having their own set of "global vars". My idea was to create an array that gets passed in, it does some work on the values of that array, then passes the array back with the updated vars. These arrays would be stored at the main's global scope.
The fact that I am calling efsInternal() multiple times, using different input vars means I can't use normal global vars (I'm assuming), so I have to come up with some way to have each one keep track of its own state.
I have two questions. One, is this the way I should approach this to begin with? Two, what is the best way to do this performance-wise (is there a way to call efsInternal() once in an Init instead of each bar? Is calling getSeries() each time very slow? etc.) ?
(I'm not sure if the following is syntactically correct)
PHP Code:
// Initial setting of the arrays (to hold the "global" vars for each call to efsInternal()
var xGlobalVars1 = new Array(0,1);
var xGlobalVars2 = new Array(2,3);
function main() {
if (getBarState() == BARSTATE_NEWBAR) {
// Call the function, passing in the "global var array", then getting back the updated arrays to be stored at this scope
xGlobalVars1 = efsInternal("doWork", xGlobalVars1 );
xGlobalVars2 = efsInternal("doWork", xGlobalVars2 );
}
}
function doWork(myGlobalVars) {
// Retrieve the individual global vars and put them into local vars
var myVar1 = getSeries(myGlobalVars, 0);
var myVar2 = getSeries(myGlobalVars, 1);
// Do some kind of work on the vars
myVar1++;
myVar2++;
// return the "global vars" in an array (which is later passed back into this function to do work again)
return new Array(myVar1, myVar2);
}
Daniel
Comment