Avoid copying code á la Wim Gielis

Post Reply
bskalli
Posts: 21
Joined: Wed May 14, 2008 7:53 am

Avoid copying code á la Wim Gielis

Post by bskalli »

I use very much the method Wim Gielis, Avoid copying code.
But I still have not found any possibility that the n-fund on the shows of the n-variable inputs,
it would be an art activation.
I do not want to know how the variable is called but its content
I speak about a text input in a ti Process

Any idee ?

if you write +Param01+ in MDX, you mean the value of your Param01.
Is there anything comparable in TI ?
bskalli
Posts: 21
Joined: Wed May 14, 2008 7:53 am

Re: Avoid copying code á la Wim Gielis

Post by bskalli »

where are our Gurus?

On vacation?
David Usherwood
Site Admin
Posts: 1458
Joined: Wed May 28, 2008 9:09 am

Re: Avoid copying code á la Wim Gielis

Post by David Usherwood »

I wish :)
I can't speak for others but I am afraid I don't have the faintest idea of what your posting was about - hence the lack of response.
drbot
Posts: 1
Joined: Thu Sep 09, 2010 2:35 pm
OLAP Product: TM1 and C8
Version: 9.5.1
Excel Version: 2003

Re: Avoid copying code á la Wim Gielis

Post by drbot »

Do you want to place parameters or variables inside an mdx-expression in a ti process?
It works with string concatenation. If your parameter name is pCountry and you want to check if it is an element of your [countries] dimension, then use
TM1FILTERBYPATTERN({TM1SUBSETALL( [countries] )},'|'"'|pCountry|'"'|')}
Watch out for single and double apostrophes - the double apostrophes are only necessary because i used TM1FILTERBYPATTERN. Otherwise '|pCountry|' should be ok.

Hope that helps
bskalli
Posts: 21
Joined: Wed May 14, 2008 7:53 am

Re: Avoid copying code á la Wim Gielis

Post by bskalli »

Thanks Drbot und David.
Short question:
how can I read data within a three loop from an input ?
Alan Kirk
Site Admin
Posts: 6647
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Avoid copying code á la Wim Gielis

Post by Alan Kirk »

bskalli wrote:Thanks Drbot und David.
Short question:
how can I read data within a three loop from an input ?
Short answer: that question isn't any clearer than your first one.

- What input, exactly? From what source? Are we talking about a process parameter? A cube view as a data source? A Text file as a data source? A CellGetN/CellGetS statement somewhere in your code?
- What do you mean by a "three loop"? Are you talking about three nested While loops? A While loop that iterates three times? Something else? Is this loop within the Prolog? Or is it on the Data tab? Or is it on the Metadata Tab? Or is it something in an obscure corner of The Discovery Channel?
- What do you mean by "read" it given that if it's an "input" it is, by definition, already "read".

As the Request for Assistance Guidelines say,
Try to make the question as specific as possible.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
bskalli
Posts: 21
Joined: Wed May 14, 2008 7:53 am

Re: Avoid copying code á la Wim Gielis

Post by bskalli »

Hello Alan,
I have a text-file as Data-Source with three variables.
I want to transfer the value of this variable within a loop.

I know that the last line is wrong:

MyDims='Column01§Column13§Column27§';
WHILE(LONG(MyDims)>0);
Column=SUBST(MyDims,1,SCAN('§',MyDims)-1);
x=+Column+;


the only solution I know is the following:
If (Colum@='Column01'); x=Column01;
ElseIf (Column@='Column13'); x=Column13;
ElseIf (Column@='Column27'); x=Colum27;
EndIf;

Hopful
User avatar
Michel Zijlema
Site Admin
Posts: 712
Joined: Wed May 14, 2008 5:22 am
OLAP Product: TM1, PALO
Version: both 2.5 and higher
Excel Version: 2003-2007-2010
Location: Netherlands
Contact:

Re: Avoid copying code á la Wim Gielis

Post by Michel Zijlema »

Posting this code fragment doesn't make it much clearer what you're trying to establish...

I assume that the WHILE statement is followed somewhere in your code by an END statement.
I see that in the WHILE statement you check for the length of the MyDims string value - is this length reduced anywhere in the WHILE loop before the END statement? Otherwise the loop will never end.
The last statement you posted contains an invalid construct - what value exactly do yo want to assign to the x variable? If this needs to be the value of the Column variable (as per your first post in this thread) than x = Column; would be sufficient (where the variable Column will contain the value 'Column01' in the first iteration of your WHILE loop).

Michel
Wim Gielis
MVP
Posts: 3230
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Avoid copying code á la Wim Gielis

Post by Wim Gielis »

Hello

Michel is right, at the bottom of the code, the string should become smaller:

MyDims=DELET(MyDims,1,SCAN('§',MyDims));

And the WHILE loop should be closed with an END;

For those interested, check out the article on my website with the same name: "Avoid copying code".

bskalli,

I more or less understand what you are trying to do. Unfortunately, in TI you cannot "create" variables out of a text string. My method, however, can be used for many other loops, cases where statements are executed for a number of similar objects. There is no better workaround than what you were proposing in your (pseudo-)code.

Wim
Last edited by Wim Gielis on Fri Sep 10, 2010 12:37 pm, edited 1 time in total.
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
bskalli
Posts: 21
Joined: Wed May 14, 2008 7:53 am

Re: Avoid copying code á la Wim Gielis

Post by bskalli »

Hello Wim, I know your code and I use it too.
You're the first who told me that there is no activation in TI.
I have my answer.
Hello Michel,
Of course there are a lot of code inside the loop,
Read attributes, arithmetic, writing in a cube ...
Thank you for your patience
bskalli
Posts: 21
Joined: Wed May 14, 2008 7:53 am

Re: Avoid copying code á la Wim Gielis

Post by bskalli »

Hello Wim, here is an example of your method without loop,
rather than one dimension to be defined with attributes.

CompanyCode='00301';

T_I='&00011&00013&00301&00338&';
T_O='&58012&58043&56002&56061&';
Firma=Subst(T_O,Scan(CompanyCode,T_I),5);


bskalli
Wim Gielis
MVP
Posts: 3230
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Avoid copying code á la Wim Gielis

Post by Wim Gielis »

You are right with the example.

Drawback is that maintenance is more difficult (changing an attribute is easier than going in the TI code - also permissions wise). Also, attributes cubes can be filled by rules for instance, here in the TI code it's hardcoded.

The loop idea can be used for fixed, rather random, enumerations, with which we will not do much in the TM1 model itself (as opposed to an alias for instance).

Thanks for reflecting on the hint I gave.

Wim
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
bskalli
Posts: 21
Joined: Wed May 14, 2008 7:53 am

Re: Avoid copying code á la Wim Gielis

Post by bskalli »

Hi Wim,
in order to avoid defining a dimension for every TI_Process , I have implemented a single dimension ,
which elements are as follows: PGMnn.Elemnn.Valuenn and some attributes.

And my former Request deals with : Valuenn.

bskalli
Post Reply