Read Next Field from File Action

image\Actions_Storage_Read_Next_Field.jpg

The Read Next Field from File action is used to retrieve information previously saved into a disk file using the Write to Disk File, or Write Text to File actions. The information retrieved is then stored in a variable for use within your Opus publication.

This action is used to read a file separated into ‘fields’. A field is the way in which one bit of data is separated from another within the disk file when it was created. In the Write to Disk File and Write Text to File actions you can separate the text you entered in the file by surrounding the text with quote marks, separated by comma’s or by a new line (a carriage return) – these are the fields to which this action is referring.

Use this action to read the first ‘field’ and then use this action every time you want to read the next ‘field’ in the disk file.

To copy ALL of the contents of the file to a variable use the Read from Disk File action. There are other actions in the Storage menu that allow you to specify particular positions in the file to read information from: Read First Line from File; Read Next Line from File; Go to Start of File; Go to Next Line in file.

Setting up the Read Next Field from File Action:

  1. Add the Read Next Field from File action to your trigger, as described in adding actions. The Read Next Field from File tab will automatically appear when you add the action.

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

Note:
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).

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 read.

  1. Tick the Get from Windows TEMP directory option if you originally saved the text during the Write action to the windows Temp directory. By default this checkbox is not ticked.

Note:
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.

  1. Click on the down arrow to the right of the Variable option, to select the name of the variable in which you want to store the text of the specified disk file.

  2. 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 click the OK button.

  3. Click on the Data is encrypted option if this option was used when you created the disk file using the Write actions. Ticking this checkbox will enable the Key field. In the Key field type the name of the key you gave to the disk file in the Write action.

  4. Click on the Fields use quote marks option if the text in the disk file is separated using quote marks. This option will select all the text within quote marks and add it to the variable.

  5. 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 Write to Disk File action