Actually we do use it, a TI i inherited had the same code repeated 230+ times in the data tab and i was asked to make a change which find and replace (using notepad

) wouldn't have done, so i found myself thinking of a better way of writing it altogether.
My datasource is a text file but ordered in tabular format (each month for up to 19 years is a seperate column of data) and the variable names for each start at V11 and go on up to V228. As the file can cover different ranges of months, it needed to allocate each variable without needing to rewrite the TI so we use an attribute to determine witch month relates to which "column".

- MthAttrb.jpg (26.72 KiB) Viewed 21280 times

- VarList.jpg (36.07 KiB) Viewed 21281 times
One TI is used to allocate the months to a month number, based on the users input for the 1st month in the file they are going to load. Once thats run and the view above is correct, the following code is used to load the data to the correct month.
Code: Select all
MonthN = 1;
VarN = 11; #this is the number of the first variable that holds the first months values
While ( MonthN <= 228 ); #228 is the max i need it to check thru
MonthS = 'Month ' | NumberToString ( MonthN ); #the element i'm looking for in the attributes (month 1, month 2 etc)
VarS = EXPAND ( '%V' | NumberToString ( VarN ) | '%' ); # the key bit, grabs the value of the variable V11, V12 etc but stores it as a string
CELLPUTN (
CELLGETN (
' Demand ', AreaPlacingWork, NewContractNo, DeptDemandPlacedOn2, ResourceTag, Nomination, Site,
ResourceSource, ContractStatus, Risk,
ATTRS ( ' Month Number ', MonthS , ' Demand Month ' ),
Version, ' Man Hours '
) + NumBR ( VarS ) , #this bit converts the expanded value to a numeric so it can be added to the existing value
' Demand ', AreaPlacingWork, NewContractNo, DeptDemandPlacedOn2, ResourceTag, Nomination, Site, ResourceSource, ContractStatus,
Risk,
ATTRS ( ' Month Number ', MonthS , ' Demand Month ' ),
Version,' Man Hours '
) ;
This isn't the full code, but its the bit the EXPAND concerns, hope it helps.
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet