Page 1 of 1

Adding a Line of Code to all TI's

Posted: Mon Sep 09, 2013 11:51 am
by Darkhorse
Hi all is this possible what im asking?

Can I get a TI to run through every TI and add a line of code to TI's already create?

Re: Adding a Line of Code to all TI's

Posted: Mon Sep 09, 2013 12:03 pm
by declanr
Not exactly, by which I mean TM1 has no built in function to do this.

However; TIs can run anything through the command line and you could probably accomplish what you want with a bit of PERL script looking at the data directory folder... of course the effort would all be in creating the PERL script and you could initiate that without a TI... so it all depends on whether it would be a one off task or a regular one.

Before taking this course of action though I would probably step back and ask if it is really worth all the risks involved and the time and effort or is there another way to get to the end goal.

Re: Adding a Line of Code to all TI's

Posted: Mon Sep 09, 2013 1:23 pm
by Darkhorse
Hi Declan

I thought as much as couldnt find any documentation in the help files but tthought to ask just incase (like many areas) you guys have a way to do it that isnt documented.

I did this task a few months ago manually it took me a while to do, just wanted to see if there was a cheeky quicker work around.. pity

*off to go edit 100 TI's.... :(

Re: Adding a Line of Code to all TI's

Posted: Mon Sep 09, 2013 1:28 pm
by Steve Rowe
Perhaps if you post a bit of background as to why you need to edit 100 TIs so often someone will be able to suggest a way of generalising your code to be maintenance free?

Cheers,

Re: Adding a Line of Code to all TI's

Posted: Mon Sep 09, 2013 5:32 pm
by Wim Gielis
If there is no way of generalising this (as pointed out by Steve), try using a text editor like Notepad++
to change the contents of the relevant *.pro files. They can be opened as text files and can be edited.
If you restart the TM1 service, the changes in the processes will be visible. Not without doing the restart.

However, please be cautious. First open up a *.pro file in a text editor, and study the structure of such a file.
You are left on your own if you change lines and numbers in there and it turns out that it messes up your processes.
For example, a .pro file will keep track of the number of code lines in each of the Advanced tabs (Prolog, Metadata, ...)
So changing lines of code in a "tab" will also mean that you need to change that number...
Hence my advice, while this is not impossible, please know what you are doing and what the potential risks are. Always have a good backup !

Re: Adding a Line of Code to all TI's

Posted: Mon Sep 09, 2013 8:14 pm
by dr.nybble
If you do want to do this I suggest writing a program to do it that uses one of the TM1 APIs.

The problems with trying to directly edit the .pro files have been mentioned. In particular, the properties that hold TI script are multi-line properties and you not only need to insert your line, but also need to update the line count associated with that property.

If you use an API you don't need to do that.

Re: Adding a Line of Code to all TI's

Posted: Mon Sep 09, 2013 8:59 pm
by Wim Gielis
dr.nybble wrote:If you do want to do this I suggest writing a program to do it that uses one of the TM1 APIs.

The problems with trying to directly edit the .pro files have been mentioned. In particular, the properties that hold TI script are multi-line properties and you not only need to insert your line, but also need to update the line count associated with that property.

If you use an API you don't need to do that.
Hi there

Just curious, do you have any pointers towards TM1 API coding with regard to TI processes?
Can it be done using the VB implementation of the TM1 API ?

Re: Adding a Line of Code to all TI's

Posted: Mon Sep 09, 2013 9:12 pm
by Alan Kirk
Wim Gielis wrote:
dr.nybble wrote:If you do want to do this I suggest writing a program to do it that uses one of the TM1 APIs.

The problems with trying to directly edit the .pro files have been mentioned. In particular, the properties that hold TI script are multi-line properties and you not only need to insert your line, but also need to update the line count associated with that property.

If you use an API you don't need to do that.
Hi there

Just curious, do you have any pointers towards TM1 API coding with regard to TI processes?
Can it be done using the VB implementation of the TM1 API ?
Yes it can (yes it has been), but it takes some work. As in, a lot of work. To be honest for a one-off like this it's questionable whether it's worth it. Unless we're talking hundreds or thousands of processes it will be way faster to just open the things in the Editorsaurus and paste the line in.

Re: Adding a Line of Code to all TI's

Posted: Wed Sep 11, 2013 12:15 am
by Darkhorse
Sorry guys meant to reply to this post.

I put some code inside the epilogue of every TI to captcha tm1 users name and date each time the TI ran this would post to my process catalogue. I posted this code in all my tis but I want to add a couple more tags of data to catch. I tried originally to use a process

I.e execute runtagdata.

But I found my system crashed a few times when tis were being ran at the same time due to this extra process being called twice and at the same time. It also didn't help when I had an execute TI that ran 5 TI's in order and a chore kick off around the same time. This tag process ran with every TI inc the execute TI and ran with the chores and there processes so it caused a lot of conflicts. so I reverted back to lines inside the TI. The draw back is I need to edit every TI again to add this new snippet of code genes my request if it was possible, but judging by replies it is best for me to just edit manually :(

Re: Adding a Line of Code to all TI's

Posted: Wed Sep 11, 2013 11:22 am
by Wim Gielis
Another question, which is related and has been raised by Steve:
Do you really need that many TI processes ?
I've seen TM1 implementations with several hundreds of cubes and TI processes, but they were already quite general.
Can you save on the number of TI processes by introducing (more) parameters ?

Re: Adding a Line of Code to all TI's

Posted: Wed Sep 11, 2013 5:07 pm
by Darkhorse
I said 100 because it feels that way when your manually doing it it was a rough guesstimate I have around 40-50 I'm modular in my approach to my TI's I am working on more dynamic max views but. We have a lot of processes going in out and sometimes just around the server.

Re: Adding a Line of Code to all TI's

Posted: Wed Sep 11, 2013 6:47 pm
by lotsaram
100 seems like a pretty small number of TI processes to me!

I agree better to suck it up and manually copy and paste than look for automating which would be much more work and may not be safe. Modular design is the way to go but it sure as hell pays to have the module design fixed up front before there are lots of objects and dependencies. Or the other way around, it sure is painful to retrospectively change something once a mudular design has been implemented!

Re: Adding a Line of Code to all TI's

Posted: Wed Sep 11, 2013 7:19 pm
by Duncan P
Code vs Repetitive Strain Injury - always a hard choice

Re: Adding a Line of Code to all TI's

Posted: Wed Sep 11, 2013 7:23 pm
by Alan Kirk
Darkhorse wrote:Look I said 100 because it feels that way when your manually doing it it was a rough guesstimate I have around 40-50 I'm modular in my approach to my TI's I am working on more dynamic max views but. We have a lot of processes going in out and sometimes just around the server.
I have to agree with Lotsaram, especially if it's 40 to 50. If you try hacking the .pro files it's not straightforward because (as Dr. Nybble mentioned) you'd need to update line counts as well as lines, you can't be certain in advance of where those lines will be in any given .pro file without writing code to parse the thing out in full, and it's just plain risky. It can be done in the API, but for this kind of thing you'd still be writing the code long after the you in a parallel universe finished manually editing all 50 (or even 100) of the things. On a cost/time basis, just doing the edit is the way to go.
Duncan P wrote:Code vs Repetitive Strain Injury - always a hard choice
Nice. But it needs a third dimension representing "fun to be had hacking out the code and uncovering new ways of doing stuff". :D

Re: Adding a Line of Code to all TI's

Posted: Wed Sep 11, 2013 10:39 pm
by Darkhorse
Duncan P wrote:Code vs Repetitive Strain Injury - always a hard choice

Must admit I always like to look for the code option first (",) but I totally agree,

Thanks guys in truth in all this time on this thread I could of done it by now :D :D

Oh we'll there's nothing like procrastinating the tough jobs... :(

Thanks guys appreciate the input