LF: Store DTI to File

Use this function to select data in a DTI and store it in a file on an SD card.
You can select the file type by storing values into parameter F, File Type to Create:

Appending Rows
You can append rows of data to a file by setting parameter E to 1.

Note that rows can
only append to a .udtf file.

For this reason, if you choose to Append Rows, you
must select file types that include .udtf, which are values 0,1,and 4. Selecting any other types will cause an error, and no file will be created.

If you want to create a final file using the .csv of .zip file types, first store 0 into parameter F; when all of the desired data has been appended and you want to close the file and save it to the SD card, store the value corresponding to the file type you want to save.
This enables the system to both work efficiently and ensures that all of the desired data is appended.


Click here to see an example.Click here to see an example.

 

Path
Note that parameter C, Destination File Name, requires you to provide only the name of the file. Do not provide the path; UniStream supplies the path automatically.

 

 

 

Parameter Name

Purpose

A

Data Table: Source

Select the Data Table to store.

B

Start Row Number (offset): Source

Assign a Data Tag or enter a constant.

The function stores the values in the source Data Table beginning from this row.

C

Destination File Name

Assign a string to provide the name of the file on the SD card.

The data will be stored into this file.

Note that:
-If a file of this name does not exist on the SD card, a file of that name will be created.
-The file name may not exceed 63 characters.

D

Number of Rows to Store

Assign a Data Tag to provide the number of rows, or enter a number.

This is the number of rows function will store.
To store the entire DTI, select the table, and the Number of Rows tagNumber of Rows tag.

E

Append

Assign a Data Tag bit to control this feature:

0 = Data will overwrite the destination file

1 = Data will be appended to the file

F

File Type to Create

Assign a Data Tag bit to control this feature. Use the values below to create the desired file type:

0 = Only .udtf file

1 = .csv .udtf, and csv.zip files

2 = Only csv

3 = Only csv.zip

4 = Formatted files: .csv .udtf, and csv.zip files

5 = Formatted .csv

6 = Formatted .zip files

G

.csv Delimiter

Assign a Data Tag to provide the character, or enter it as a constant. For example, to enter a comma, place the comma between quotation marks:
","

H

Digitally Sign file

Assign a Data Tag to decide whether or not to digitally sign the file: 0 = Don't sign 1 = Sign

I

Status

Assign a Data Tag to hold the function’s status messages.

When using Store DTI to File followed by Load from File:
- Allow approximately 15 seconds for the Store function to complete its procedure before activating the Load function.
- Check the status of the Load function.
- If status ≠ 0, wait 1 second and run Load again.

See LadderSee Ladder

 

 

Code

Message

1

Function in progress

0

No errors

-1

Function failed

-2

Internal error. Contact Support.

-3

General Error.

-4

Internal error. Contact Support.

-5

Read file error

-6

Write file error

-7

CRC error. The structure of the Data Table and the external file do not match

-8

Signature file error

-9

PLC Data Table cannot be stored to external file

-10

External File cannot be loaded to PLC Data Table

-12

Internal error. Contact Support.

-13

Function Failed

-14

Append file error, no file created; see Help topic LF: Store DTI to File for more information

-31

Number of lines in file is 0

-32

File Name missing: the file name parameter is empty within the function

-33

The number of lines specified in the function exceeds the number of lines that are in the Data Table

-34

The file name exceeds 63 characters

-35

Too many requests

-36

Internal error. Contact Support.

-37

Download in Progress

-38

Array locked by other utility

 

Related Topics

Data Tables

Creating a Data Table

Data Table: Indexed (DTI)

LF: Write Row to DTI

LF: Read Row from DTI to Struct

LF: Insert Row to DTI

LF: Remove Row from DTI

LF: Clear DTI Row

LF: Find Value in DTI Column

LF: Copy DTI Column into Array

LF: Write value to DTI Column

LF: Load DTI File to PLC Data Table (SD)

LF: Clear DTI