Global Variables in TI
Posted: Fri Apr 15, 2011 6:16 pm
Just wanted to ask if anyone has encountered any issues using these? I have and just wanted to ask if anyone has experienced similar. Using v951 with HF15.
So two TIs, one calls the other.
In the prolog of both TIs I define sCubeName to be a global string variable.
I populate it in the prolog of the first TI, it's a hardcoded reference to the same cube on every run.
In the second TI I have
sTS=CellGetS( sCubeName, etc all hardcoded);
99% of the time this works fine and the 2nd TI correctly references sCubeName
On a small number of occasions I get an error saying that cube "" not found relating to the line above. I'm taking this to mean that sCubeName is not populated when CellGet is run, this implies that global vars are not 100% reliable. (It's early days in this so don't go rewriting your TIs just yet!). I don't normally use global vars, tending to pass parameters from one TI to another so just wanted to check if I am missing a trick?
Does anyone know how global vars work under the hood?
The issue seems erratic with a tendancy to occur if I run the TI sequence twice in quick succession so I am wondering if the global var is cached in some way. When the cache from the first run is cleared it's impacting the global vars from the second run which has already started.
Something like this.
Second 1 : TI 1 Pass 1 ; declare sCubeName to be a global var and populated it, call TI2
Second 2 : TI 2 Pass 1 ; correctly reference sCubeName
Second 3 : Pass 1 ends.
Second 4 : TI 1 Pass 2 ; declare sCubeName to be a global var and populated it, call TI2
Second 4.5 : Global var cache from pass 1 is cleared.
Second 5 : TI 2 Pass 2 ; reference to sCubeName fails following destruction of cahce.
The above is just conjecture, anyone have a better idea if this is a bug or a feature? I'm 99.99% this is not user/code error.
Anyway I'm off on two weeks leave, woo hoo, so consider this a parting gift.
Cheers,
Steve
So two TIs, one calls the other.
In the prolog of both TIs I define sCubeName to be a global string variable.
I populate it in the prolog of the first TI, it's a hardcoded reference to the same cube on every run.
In the second TI I have
sTS=CellGetS( sCubeName, etc all hardcoded);
99% of the time this works fine and the 2nd TI correctly references sCubeName
On a small number of occasions I get an error saying that cube "" not found relating to the line above. I'm taking this to mean that sCubeName is not populated when CellGet is run, this implies that global vars are not 100% reliable. (It's early days in this so don't go rewriting your TIs just yet!). I don't normally use global vars, tending to pass parameters from one TI to another so just wanted to check if I am missing a trick?
Does anyone know how global vars work under the hood?
The issue seems erratic with a tendancy to occur if I run the TI sequence twice in quick succession so I am wondering if the global var is cached in some way. When the cache from the first run is cleared it's impacting the global vars from the second run which has already started.
Something like this.
Second 1 : TI 1 Pass 1 ; declare sCubeName to be a global var and populated it, call TI2
Second 2 : TI 2 Pass 1 ; correctly reference sCubeName
Second 3 : Pass 1 ends.
Second 4 : TI 1 Pass 2 ; declare sCubeName to be a global var and populated it, call TI2
Second 4.5 : Global var cache from pass 1 is cleared.
Second 5 : TI 2 Pass 2 ; reference to sCubeName fails following destruction of cahce.
The above is just conjecture, anyone have a better idea if this is a bug or a feature? I'm 99.99% this is not user/code error.
Anyway I'm off on two weeks leave, woo hoo, so consider this a parting gift.
Cheers,
Steve