Dynamic Assignment of Variable Names
Posted: Thu Jun 25, 2009 9:44 am
Not sure if this can be done in TI or not, but it'd be damn helpful if it could.
I have a need to export data using asciioutput in a tabular format, with variables down the left and months across the top. Normal export like this would put one value per line, so the same variables that had data against 200 months would create 200 seperate lines of data.
I could manually create 200 variables (M1, M2, M3 etc) and use CellGetN to grab the number, but i'd prefer to write a loop that goes through the subset of months i'm interested in, iterates the variable name and assigns the value that way. TI doesn't seem to want to do this tho, something along these lines will not save.
It doesn't like anything other than "hardcoded" variable names. Expand can help but only if they are in the variables tab - i can't iterate the number there so its of little use. Anyone know of a different way to approach this, or am i stuck with lots of lines of code?
TIA
I have a need to export data using asciioutput in a tabular format, with variables down the left and months across the top. Normal export like this would put one value per line, so the same variables that had data against 200 months would create 200 seperate lines of data.
I could manually create 200 variables (M1, M2, M3 etc) and use CellGetN to grab the number, but i'd prefer to write a loop that goes through the subset of months i'm interested in, iterates the variable name and assigns the value that way. TI doesn't seem to want to do this tho, something along these lines will not save.
Code: Select all
#test code for dynamic variable names
nSub = 1;
While ( nSub <= 5 );
'M' | NumberToString (nSub) = nSub;
End;
TIA
