Write to Disk File Action

image\Actions_Storage_Write_Disk.jpg

The Write to Disk File action allows you to write information in a variable to a disk file. A disk file is a plain text file (a file with the .txt file extension).

Note:
You can write to the same disk file as often as you like. In other words, information from a variety of variables (or even the same variable which may have new data in it) can be appended to the end of the disk file. Alternatively, new data can overwrite the existing data on the disk file.

There is also a Write Text to File action if you want to enter text in a file without using a variable to store the data.

Setting up the Write to Disk File Action:

1. Add the Write to Disk File action to your trigger, as described in adding actions. The Write to Disk File tab will automatically appear when you add the action.

2. Click on the down arrow to the right of the Variable option to select the name of the variable containing the information you want to store.

Note:
You can copy the contents of any variable into the disk file; this may be a single word, numbers or even several lines of text.

3. Click on the New… button if have not created the variable yet. This will open the New Variable dialog box. In the dialog box, type a new name for the variable and add the contents in the Value field.

Note:
If the information you want to add to a disk file is not stored in a variable already, you can create a new variable here and type the contents you want to add to the disk file ‘on the fly’.

4. Click on the down arrow to the right of the Filename option, to select the name of the disk file you want to store the information in. Alternatively, use the Browse… button to locate an existing file on a disk. The full pathname of the file you enter in this box is shown in the Filename field.

 You can enter variables into the Filename field – the variable should contain a valid pathname for the file (see Using variables to create pathnames for more information).

 If the name of the file you enter does not exist, the file will be created when this action is triggered in the publication.

The file can be on a hard disk, a networked drive or floppy disk. If the network or floppy disk is not available when the publication is run, no warning message will appear and the data is not stored.

5. Tick the Store in Windows TEMP directory option if you want to use the Temp directory in Windows rather than create your own folder in which to store the file. By default this checkbox is not ticked.

Note:
Opus can always find out where the TEMP directory is located on any computer and it will always be in a location that can be written to. If you use this option, the Filename field should only contain the name of the text file and not a pathname e.g. results.txt is correct while c:\studentFolder\results.txt would be incorrect.

6. Use the Overwrite existing contents option if you want to delete the current contents of the text file and replace it with the contents of the variable you have entered in the Variable field.

7. Use the Add to existing contents option if you want to add the new information to the file.

Note:
Selecting this option will make the following options available: Start new line, Comma separated and Use quote marks checkboxes.

8. Click the Start new line option if you want the new information to start on a new line in the text file.

9. Click the Comma separated option if you want to place a comma after the new information you add to the file.

10. Click the Use quote marks option if you want to surround the new information added to the text file with quote marks.

Note:
 These three options are particularly useful if you later decide to use this file in a database, spreadsheet or listed in a table in a text document because most word processing, spreadsheet and database applications allow you to import ‘comma separated’ or ‘quote mark’ text as separate fields so they can be easily lined-up in cells, columns or rows.

11. Click on the Encrypt Data option if you want to stop your data from been easily read by someone else. Ticking this checkbox will enable the Key field. In the Key field type a key (similar to a password) in the edit box provided.

 The key can be any combination of letters and numbers in both uppercase and lowercase. We recommend the key should be at least six characters long. You will need to remember this key or you will not be able to read the information from the file again.

If you do not enter a key, Opus will use its own default key to encrypt the data. When you use the Read from disk file action to read data from the file, you must ensure that you leave the Key edit box blank.

12. Click on the Apply button to save your changes.

Note:
This action will only work for publications that you have published using the Create a Standalone Publication option in the Publish Wizard.

Related Topics:

Introducing the Storage Actions

Restrictions Reading and Writing Disk Files

Using Variables to Create Pathnames

Disk Files vs Windows Registry

 

the Read from Disk File action