TimeDiff interval check
Moderators: Dorian (MJT support), JRL
TimeDiff interval check
Over the last months I noticed a very strange behaviour with on one of my large scripts. I couldn't find the problem because it was each time something else what happened, however it looked like that was caused by a memory issue. Now I found the problem. Somewhere in the script I used a variable name 's' which got the value 'Germany'. Much deeper in the code I used a few times the TimeDiff function making that the problem started. This is of course caused by the reason that TimeDiff uses 's' for the interval check in seconds and now this 's' became 'Germany'. The program didn't generate a error message and even the first few calls of TimeDiff worked normal, but after then the problems started. It is now solved by changing my variable name 's' in something else and to be sure I also pass the interval to timediff now as {"S"} instead of just S. I observed that the TimeDiff function can cause some severe (memory) issues if the wrong interval parameter is passed. I want to suggest that you would first check the interval parameter in the TimeDiff function and reply with a error message it it does not match 'S', 'M' or 'H'.
- Grovkillen
- Automation Wizard
- Posts: 1128
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: TimeDiff interval check
Those variable names made me pull my hair as well. It's a nice feature though so I now always add the sub routine name as the prefix. I.e.
SRT>TimeCheck
Let>TIMECHECK_S=blabla
END>TimeCheck
SRT>TimeCheck
Let>TIMECHECK_S=blabla
END>TimeCheck
- Dorian (MJT support)
- Automation Wizard
- Posts: 1378
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: TimeDiff interval check
Single letter variable assignments should be avoided, and this is one very good reason why. We see this quite often when people are reading from Excel and they'll assign a variable according to the column they're reading. Col_S would be a lot less dangerous than simply S, for example.
Yes, we have a Custom Scripting Service. Message me or go here