Dynamic variables
Posted: Tue Nov 06, 2012 10:13 pm
Hi all,
I was wondering if it was somehow possible to generate or declare variables dynamically within a TI process. Say, i would like a loop to generate a new variable, but only if a condition is met. As an example i think of looping through cube-dimensions and assign a variable (SrcDim1 -> SrcDimN) and give them the current Dimension name as value.
Simplified example:
DimCount=1;
While(TABDIM(SrcCube, DimCount) @<>'');
CurDim = TABDIM(SrcCube, DimCount);
SrcDim | Dimcount = CurDim;
DimCount = DimCount + 1;
END;
Obviously this 'concatenation' of SrcDim and DimCount wouldn't work, but i was wondering if there is any way to achieve this. I have searched extensively and did not find any workable solution that actually creates new variables when and only if needed. I only found general code which works for a fixed maximum number of (in this case) dimensions.
So, since I believe this is actually not possible I was about to give up on this idea. But of course i wouldn't do this without consulting all of your valuable experience...Anyone with a solution or workaround? Or confirmation that this IS indeed impossible?
Thx and regards,
Rob
I was wondering if it was somehow possible to generate or declare variables dynamically within a TI process. Say, i would like a loop to generate a new variable, but only if a condition is met. As an example i think of looping through cube-dimensions and assign a variable (SrcDim1 -> SrcDimN) and give them the current Dimension name as value.
Simplified example:
DimCount=1;
While(TABDIM(SrcCube, DimCount) @<>'');
CurDim = TABDIM(SrcCube, DimCount);
SrcDim | Dimcount = CurDim;
DimCount = DimCount + 1;
END;
Obviously this 'concatenation' of SrcDim and DimCount wouldn't work, but i was wondering if there is any way to achieve this. I have searched extensively and did not find any workable solution that actually creates new variables when and only if needed. I only found general code which works for a fixed maximum number of (in this case) dimensions.
So, since I believe this is actually not possible I was about to give up on this idea. But of course i wouldn't do this without consulting all of your valuable experience...Anyone with a solution or workaround? Or confirmation that this IS indeed impossible?
Thx and regards,
Rob