DASYLab Techniques
Create a worksheet that saves a new file at midnight every day , DASYLab Full and Pro
This document describes how to create a worksheet that saves a new file at midnight every day.
For measurement tasks that run over multiple days, weeks or months, it can be useful to create a new data file everyday, rather than to have all of the data in one file with multiple days. DASYLab Full or Pro can be configured to start anew file at midnight. Because this feature uses the Action module, it will not work in DASYLab Lite or Basic. DASYLab
2016 is used in the figures, but this technique applies to earlier and future versions of the software.
The example described will show you how to configure a file name that incorporates the year, month and day. At
midnight every night, an Action module will tell the Write Data module to close the current file and reopen. It will reopen using the current values of year, month and day, creating a new file with day changed.
Similar techniques can be used to start a new file every week, or every month. The common theme is that an Actionable
event has to be configured to direct the Write module to change the filename. The DASYLab Write Data module will not
automatically change the file name when the underlying variable or string changes; it takes the Action module or a Key
Action to direct the Write Data module to save the file and update the file name using the current values of variables
and strings.
Use your current worksheet to configure the DASYLab Write Data module to use a filename that incorporates the date,for example: 2020-03-10-TestData.asc. The date is incorporated using the Global String feature. Then, add Time Baseand Action modules to control the file name change.
DASYLab will not automatically change the file name. Use an Action module to control when the file name changes.

Worksheet Overview
If you don't have a worksheet, you can build this one. The figure shows the completed worksheet, using the default
module properties. You can modify an existing worksheet by editing the properties of the Write Data module and adding
two modules, a Time Base module for an event at midnight and an Action module to react to the event.
For help on setting up the Write Data module as an ASCII file, see "Saving DASYLab data to an ASCII (text) readable file"on the DASYLab Resources page.

DASYLab Techniques: Create a worksheet that saves a new file at midnight every daSet up the file name in the Write Data module
Open the Write Data module properties. Configure “Combi” for the Filename and path setting. In the entry box, you will
set up the file name to use System Global Strings.

How to insert a Global StringDASYLab offers a number of system global strings with information that is known to the program. The date and time areexamples of strings that DASYLab knows. Unfortunately, the standard format for the date often includes characters thatare not allowed in file names, for example, a date formatted as 1/5/2011 includes the “/” character, which is notallowed in a file name. Similarly, the time 10:23 PM includes a “:” character. To avoid this problem, DASYLab has Global
Strings for the Year, Month, Day, Hours, Minutes, and Seconds.
DASYLab allows you to select the strings from a list. To open the list, position the cursor in the file name entry box, at theposition where you want to include the year. Right click to open the context menu and select Global String.

DASYLab Techniques: Create a worksheet that saves a new file at midnight every daSelect YEAR. This is a four digit year, such as 2016. If you prefer a two digit year, choose YEAR_2, further down the list.
Click OK, and DASYLab will insert ${YEAR} (or ${YEAR_2}) as a placeholder in the file name.

Repeat this same process to enter the ${MONTH_LZ} and ${DAY_LZ}. These two strings include a leading zero for single
digit months and days, so that your file names will sort correctly. Use hyphens or underscores for punctuation. For
example, C:\Users\Public\Documents\DASYLab\14.0.0\ENG\data \${YEAR}-${MONTH_LZ}-${DAY_LZ}-TestData.ASC, will
create a filename that looks like this: C:\Users\Public\Documents\DASYLab\14.0.0\ENG\data\2016-11-02-TestData.ASC.

Click OK to close the properties dialog. This is all that the Write Data module needs. At Measurement Start, DASYLab will
replace the placeholders with the actual values as shown at the bottom of the Write Data properties.
Next, add the timing logic so that the file name will change when the date changes at midnight.

DASYLab Techniques: Create a worksheet that saves a new file at midnight every da

Add the Timing Logic
After you save the Write Data module settings, move to an open area of the worksheet. Add a Special→Time Base
Module. Configure it to Generate time data.

Open the module properties, and configure the Time Base module to Pulse at Midnight. Click OK to save the modulesettings.

At midnight, the Time base module will output a single pulse of 0V to 5V to 0V.

DASYLab Techniques: Create a worksheet that saves a new file at midnight every da
Add a Special→Action Module to the worksheet.

Open the module properties to configure it. Change the settings to:
Receiver: your Write module
Event: Rising Edge
Action: Close and reopen File

Save the Action module settings by clicking on the OK button.
Connect the output of the Time Base module to the input of the Action module.

When the Time Base module pulses at midnight, the Action module will tell the Write Data module to close and reopen
the file. When it reopens, it will check the current values of the Global strings and use them in the file name.

DASYLab Techniques: Create a worksheet that saves a new file at midnight every da

Other Events
In addition to pulse at midnight, the Action module can respond to other events. For example, use the Read Global
Variable module to read the ${WEEK_DAY} system variable. It is a number from 0 to 6, where Sunday is 0, and Saturdayis 6. To change the filename at the end of the week, when the weekday changes from 6 to 0, you can use a Falling edge
event in the Action module. Read the system variable using the Read Variable module, and connect it to the Action
module.
To change every month, you would use the ${ACTUAL_MONTH} system variable and the Event is “Input Value Changed”.
Search the Help Index for “System variables” to get a complete list of available variables.

SummaryYour worksheet is now configured to use the current date as part of the file name, and the Timebase and Action
modules tell DASYLab to close and reopen the file at midnight. If the value of the strings has changed, as they will at
midnight, then DASYLab will start a new file using the new values, in this case, the current date.

More information on Global StringsDASYLab has 999 strings in order to read, to change, and to transfer alphanumeric strings (text) during a measurement.
Strings can be used in a variety of ways, including as file names or parts of file names, as discussed in this document.
Strings can entered at measurement start or on demand, using the Action module or Key Actions. Use strings todocument the test, for example, with part numbers, work orders, serial numbers, or other relevant test information andautomatically include that information in the data file.
Use the Options Menu, Global Variables and Strings to define and review the strings used in a worksheet.
You can use the System strings to access internal program information such as worksheet name, author, or date. To
select a string in the context menu right-click an entry field in a dialog box.
You also can name strings. The default name is in the form ${Str_13}. You can define a name using the Advanced buttonin the Options menu, Define Global Strings. The name is uppercase only, and must start with a letter. You cannot use
spaces or other special characters. You can use the underscore _ character to make the name readable.
Review the Help sections on Global Strings for more information.