Hi Folks.
I have a nice script that runs every hour from 6am to 10pm taking readings from two networked XML files, does some math, writes the values to a SQL table and reports the data in an MS Teams Chat. The data is related to production and accounts for the productivity of two specific pieces of machinery. If one of the machines is offline due to maintenance of a failure, that is reported back in Teams and the data for the machine that is still online is reported on. If both machines are offline (production finished early or doesn't work as late on a Saturday or Sunday), my script reports that as well.
So my questions is how granular can I get with controlling the script? I'm thinking that if the script reports twice that both machines are offline, I'd like to reset until the following scheduled day at 6am. As of now it will just report no machines online every hour until 10pm.
I'd love to hear how others may have solved this problem and what options exist. -Thanks.
Script Control Granularity
Moderators: Dorian (MJT support), JRL
- Dorian (MJT support)
- Automation Wizard
- Posts: 1378
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Script Control Granularity
The first idea that comes to mind is using the ini file functions to track the results.
Also making sure to reset the ini file on the first run of the day.
Also making sure to reset the ini file on the first run of the day.
Yes, we have a Custom Scripting Service. Message me or go here
- Grovkillen
- Automation Wizard
- Posts: 1128
- Joined: Fri Aug 10, 2012 2:38 pm
- Location: Bräcke, Sweden
- Contact:
Re: Script Control Granularity
If you use an external scheduler which triggers the script I would use Dorian's suggestion using a ini file. If you use a loop and keep the script running at all time (internal scheduler) you could keep a variable for keeping track of what to do. I have used both approaches and non is superior, only different ways of doing it.
Re: Script Control Granularity
That seems like a pretty good first thought... but alas I have questions.
Assuming we are talking about the runstats.ini file, can I edit that to include additional 'fields' for each section? So instead of this...
Can I add edit it to include more information like this...
Assuming we are talking about the runstats.ini file, can I edit that to include additional 'fields' for each section? So instead of this...
Code: Select all
[C:\Users\Mentor\Documents\Macro Scheduler 15\NYTunnelTransfers.scp]
LastElapsedTime=00:00:18
LastRun=5/8/2023 8:01:19 AM
ElapsedTotal=09:38:49
NumRuns=415
NumLines=426
LinesLastExecuted=193
AverageExecutionTimePerLine=93
NumErrors=0
Code: Select all
[C:\Users\Mentor\Documents\Macro Scheduler 15\NYTunnelTransfers.scp]
LastElapsedTime=00:00:18
LastRun=5/8/2023 8:01:19 AM
ElapsedTotal=09:38:49
NumRuns=415
NumLines=426
LinesLastExecuted=193
AverageExecutionTimePerLine=93
NumErrors=0
NumRunsToday=0
T1Offline=0
T2Offline=0
- Dorian (MJT support)
- Automation Wizard
- Posts: 1378
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Script Control Granularity
No, not that one. I'm referring to creating an ini file for the specific data you wish to track.
You can put whatever you like in your ini file. I suggest playing with EditiniFile and ReadiniFile using the examples shown.
Create the ini file first using notepad (or writeln if you wish).
So something like this :
So you can keep track and add one to the appropriate values, or zero them out, as needed. You just need to integrate it into the appropriate places within your script.
You can put whatever you like in your ini file. I suggest playing with EditiniFile and ReadiniFile using the examples shown.
Create the ini file first using notepad (or writeln if you wish).
So something like this :
Code: Select all
Let>MyInifile=d:\mynewini.ini
IfNotFileExists>MyInifile
writeln>MyInifile,,
endif
Let>NumRunsToday=0
Let>T1Offline=0
Let>T2Offline=0
EditIniFile>MyInifile,tracking,RunsToday,NumRunsToday
EditIniFile>MyInifile,tracking,T1off,T1Offline
EditIniFile>MyInifile,tracking,T2off,T2Offline
Yes, we have a Custom Scripting Service. Message me or go here