<< Click to Display Table of Contents >> Using the date & time for a Log Report filename |
![]() ![]() ![]() |
This example shows how to create a filename containing the date & time for use when generating Log Reports:
There are many ways to do this depending on exactly what is wanted.
For example, the filename may need to be built up from a combination of the line name, product name, batch name and date & time. Part of this may be from a scanned barcode. The triggering of the Log Report would typically be triggered automatically by the Strategy Controller when the process starts.
However, for this simple example, the filename will just be the date & time and the triggering of the Log Report will be done by clicking a button.
Create the following User Variables:
DateTime: StartDateTime & StopDateTime
Text: LogFileName
Bool: LogReportButtonClickedBool
Then put the variables on the screen (GDW):
Put a button on the screen to be used to trigger the Log Report:
Go into Runtime Mode and setup a Log Report Format as shown:
Go back to Edit Mode (Offline) and from the Setup menu choose Strategy Controller.
Note: For this example only one Strategy Event is required, and as 2 Strategy events are included as part of the base product there is scope to add more. However, if more than 2 events are needed then the Strategy Controller option will need to be purchased.
The Event is: If LogReportButtonClicked is equal to 'On'
The Actions for this event are:
Set LogReportButtonClicked to Off - (Ready for the next time, using: 'Parameters: Download Specific Value')
Set StopDateTime to current time - (Using: 'Parameters: Download Specific Value' to set StopDateTime to 'Current time')
Copy StopDateTime to filename - (Using ''Parameters: Copy From … To' to copy the StopDateTime to the filename)
Generate Log Report - (Use 'Logging: Convert Specific Log File Format' and choose the Log Report Format that was created in the previous step)
Set StartDateTime to now - (Using: 'Parameters: Download Specific Value' to set StartDateTime to 'Current time' ready for the next Log Report)
From the File manu choose Preferences, click the 'Display' tab and set the 'Date Time Format' format so that it is: %y-%m-%d_%H-%M-%S
This will ensure that when a Date Time variable is used for a filename the files will be in date order when sorted by name.
Then click return to Runtime Mode and click the 'Create Log File Report' button.
The Log Report file itself will be in the project's folder and can be opened either in Microsoft Excel or in any text editor such as Wordpad.