Hello all,
Whenever I have a code that makes efsExternal calls to another scripts, I found that, during reload, those scripts are always more than once. I'm wondering if somebody can shed some light on this. The following is a sample skeleton script:
var gbInit = true;
var gmA;
var gmB;
var gsA;
var gsB;
function main() {
if (gbInit) {
gmA = efsExternal ("a.efs");
gsA = getSeries (gmA, 0);
gmB = efsExternal ("b.efs");
gsB = getSeries (gmB, 0);
gbInit = false;
}
// process and return something
}
The following are what I found out, and please if somebody could tell me why, let me know:
1) Per the code is written above, whenever I do a **reload** of the script, "A" is always executed twice, whereas "B" is executed once. Why couldn't "A" just be executed once?
2) Furthermore, the second time "A" is executed, it retains the last value of all its global variables, which is understandable, but causes frustration, since the "second" execution of "A" may produce a different (and wrong) result than the first, and these wrong results are the one used by the main script. I know... I can make provisions to always reset all global vars during "all bars", but it's too cumbersome.
3) By the way, in the code above, if I swap the order of efsExterncall calls, to "B" being the first, and "A" being the second; during ***reload*** code "B" will be excecuted twice, while "A" executed only once.
So, I guess, in the case of multiple efsExternal calls within a script, during reload, the first call will always be executed more than once. All I'm asking is why is this necessary, and how I should go about preventing this multiple executions to happen.
Thanks,
Yonas
Whenever I have a code that makes efsExternal calls to another scripts, I found that, during reload, those scripts are always more than once. I'm wondering if somebody can shed some light on this. The following is a sample skeleton script:
var gbInit = true;
var gmA;
var gmB;
var gsA;
var gsB;
function main() {
if (gbInit) {
gmA = efsExternal ("a.efs");
gsA = getSeries (gmA, 0);
gmB = efsExternal ("b.efs");
gsB = getSeries (gmB, 0);
gbInit = false;
}
// process and return something
}
The following are what I found out, and please if somebody could tell me why, let me know:
1) Per the code is written above, whenever I do a **reload** of the script, "A" is always executed twice, whereas "B" is executed once. Why couldn't "A" just be executed once?
2) Furthermore, the second time "A" is executed, it retains the last value of all its global variables, which is understandable, but causes frustration, since the "second" execution of "A" may produce a different (and wrong) result than the first, and these wrong results are the one used by the main script. I know... I can make provisions to always reset all global vars during "all bars", but it's too cumbersome.
3) By the way, in the code above, if I swap the order of efsExterncall calls, to "B" being the first, and "A" being the second; during ***reload*** code "B" will be excecuted twice, while "A" executed only once.
So, I guess, in the case of multiple efsExternal calls within a script, during reload, the first call will always be executed more than once. All I'm asking is why is this necessary, and how I should go about preventing this multiple executions to happen.
Thanks,
Yonas
Comment