Page 1 of 1

Insert delay in TI process

Posted: Mon Jul 12, 2010 12:38 am
by Anthony@GE
New to the forum - so apologies if this is in the wrong place.

I've set up email notification via BLAT and want to send out an email to a distribution list 10 minutes before a certain TI process runs.
ie.,
* execute command line to send email
* wait set period (ten minutes)
* execute process

Have been searching but cannot find anything that helps. Any ideas on how to do this?
I'm not overly technical so looking for a method within my limited intellect....

Thanks in Advance.
Anthony

Re: Insert delay in TI process

Posted: Mon Jul 12, 2010 2:08 am
by rkaif
You can create a Process which sends the email and put this in a separate Chore. Lets name this chore as Chore A.

Now create another chore (Chore B) and put your other processes in this chore.

Set Chore A to run 10 minutes before the Chore B.

Hope this is what you are looking for.

Re: Insert delay in TI process

Posted: Mon Jul 12, 2010 4:04 am
by LoadzaGrunt

Code: Select all

DoingNothingCounter=100000000;
WHILE(DoingNothingCounter>0);
  DoingNothingCounter=DoingNothingCounter-1;
END;
Then just change 100000000 to whatever works for you in terms of a delay.

Re: Insert delay in TI process

Posted: Mon Jul 12, 2010 4:12 am
by Alan Kirk
LoadzaGrunt wrote:

Code: Select all

DoingNothingCounter=100000000;
WHILE(DoingNothingCounter>0);
  DoingNothingCounter=DoingNothingCounter-1;
END;
Then just change 100000000 to whatever works for you in terms of a delay.
He wants a delay of 10 minutes, though. 10 seconds is one thing but I wouldn't be doing a TI loop for 10 minutes. Users may get a bit upset with the performance hit.

Chore scheduling (as per Rizwan's suggestion) is the easiest way but it presupposes that Chore A (and therefore Chore B) will run at a certain specified time and not on an ad hoc basis.

If that's not the case, and given that there aren't any TI commands to change chore scheduling (which would be an enhancement), probably the only practical way would be to have Chore B on a short cycle; say once per minute. When Chore A runs it could punch a time code into a control cube. Chore B could check the time code and if it's > 10 minutes later then it executes and clears the time code, otherwise it just quits.

However if the times are fixed, it's much better to do it by standard chore scheduling.

Re: Insert delay in TI process

Posted: Mon Jul 12, 2010 4:25 am
by Anthony@GE
Thanks for the response.

While two separate schedules is probably the easiest approach I really don't like the disconnect between the two activities (email on one schedule and TI process on another).

I'll give your approach a shot Kirk - send email on a schedule, push out a NOW() parameter to a control cube, and then have the second step monitor the difference between the initial NOW() and the current and when the difference is > 10 minutes trigger.

I've setup the first part - pushing the current time into the cube.
Don't suppose you can advise how I can have the current time (as a control) in the cube at the same time (rather than pushing it in via TI I'd want to have it be continually updated) - like a clock readout within the control cube. Is this possible? I originally thought I could put it in via rules but realise this won't work...

Thanks!

Re: Insert delay in TI process

Posted: Tue Jul 13, 2010 8:00 am
by Martin Erlmoser
process1 sends mail and executecommand schtask *or whatever (task will be scheduled)
scheduled task runs 10minutes after it - however, should be possible, didn't thought about it more detailled
scheduled task executes Tm1processexecute.exe which starts process2


or just executecommand sendmail usw & wait & tm1processexecute.exe which starts proc2, without setting executecommand wait parameter to 1..

Re: Insert delay in TI process

Posted: Tue Jul 13, 2010 2:21 pm
by ParisHilton
I'm not familiar with BLAT, but could it hold the wait for ten mins and then trigger the second TI process for you?

Re: Insert delay in TI process

Posted: Fri Nov 06, 2015 10:43 am
by robert
I'm using a little "sub"process.

With an input parameter pWaitSec
and this code in prolog:

Code: Select all


sNow = NumberToString(now);
nTrenner = Scan('.', sNow);
sTage=subst(sNow, 1, nTrenner - 1);
nSecGesStart = StringToNumber(sTage) * 86400;
nSecSinceMn = StringToNumber(TimSt (Now, '\h')) * 3600;
nSecSinceMn = nSecSinceMn + StringToNumber(TimSt (Now, '\i')) * 60;
nSecSinceMn = nSecSinceMn + StringToNumber(TimSt (Now, '\s'));
nSecGesStart = nSecGesStart + nSecSinceMn;

#asciioutput('c:\temp\test.txt', TimSt (Now, '\Y \M \d \h \i \s'));


nWaitSec = pWaitSec;

WHILE(nWaitSec>0);  
  sNow = NumberToString(now);
  nTrenner = Scan('.', sNow);
  sTage=subst(sNow, 1, nTrenner - 1);
  nSecGesNow = StringToNumber(sTage) * 86400;
  nSecSinceMn = StringToNumber(TimSt (Now, '\h')) * 3600;
  nSecSinceMn = nSecSinceMn + StringToNumber(TimSt (Now, '\i')) * 60;
  nSecSinceMn = nSecSinceMn + StringToNumber(TimSt (Now, '\s'));
  nSecGesNow = nSecGesNow + nSecSinceMn;

  nWaitSec = nSecGesStart + pWaitSec - nSecGesNow;

END;

#asciioutput('c:\temp\test.txt', TimSt (Now, '\Y \M \d \h \i \s'));

Re: Insert delay in TI process

Posted: Fri Nov 06, 2015 11:01 am
by qml
A much easier option is to use the TI function SLEEP(). It takes one parameter, which is the number of milliseconds to wait for. So SLEEP( 1000 ) will wait for one second. In addition to being simple it also doesn't unnecessarily eat up CPU resources.

And funnily enough, this function can also be used in rules. It returns the value you specified in the parameter and takes as long to calculate as you specified. So you can create slow-calculating rules by design. True story.

Re: Insert delay in TI process

Posted: Fri Nov 06, 2015 12:02 pm
by Wim Gielis
qml wrote:And funnily enough, this function can also be used in rules. It returns the value you specified in the parameter and takes as long to calculate as you specified. So you can create slow-calculating rules by design. True story.
If we insert a negative value for that parameter, can we then speed up some rules calculations ?

Re: Insert delay in TI process

Posted: Fri Nov 06, 2015 12:50 pm
by lotsaram
robert wrote:I'm using a little "sub"process.

With an input parameter pWaitSec
and this code in ...
Hi Robert,
Das oben sieht ein bistl umständlich aus. Hier ist besser.

Code: Select all

nTime = NOW();
nStartNow = nTime;
nWaitTime = nStartNow + ( StringToNumber( pWaitSec ) / 86400 );

WHILE( nTime <= nWaitTime );
  nTime = NOW();
END;
This gets the same result as your code without all of the unnecessary conversions (it is from Bedrock.Server.Wait)
But as qml suggests this is much better still and without running the CPU.

Code: Select all

Sleep( pWaitSec * 1000 );
But so long as this function remains undocumented, and others like Break, then many people will not use it just in case IBM should remove support in the future...

Re: Insert delay in TI process

Posted: Fri Nov 06, 2015 2:52 pm
by qml
If someone is really allergic to undocumented functions then something like the following should also do the trick:

Code: Select all

sWaitMS = TRIM( STR( pWaitSec * 1000, 15, 0 ) );
ExecuteCommand( 'ping 127.0.0.1 -n 1 -w ' | sWaitMS |' > nul', 1 );
Personally, I would never reject the usage of something in TM1 just because it's undocumented or documented poorly. In IBM's case claims that undocumented=unsupported are usually unfounded. It's just that they are very bad at keeping their documentation up to date, correct and complete.

Re: Insert delay in TI process

Posted: Tue Nov 24, 2015 10:56 pm
by vinnusea
Hi,
Am trying to use Blat to send emails from TM1. Would you please send me the syntax that i can use in TI ?.
Greatly appreciate for the help...

THanks,
Pat

Re: Insert delay in TI process

Posted: Wed Nov 25, 2015 4:47 am
by BariAbdul