Type
Processing Command


Purpose
The export command exports data from the current application to an external file. The export command functions like choosing File>>Export in User View.


Syntax
export to " FILENAME "
.form headerTEXT | FIELDNAME
.items@f[FORM NUMBER, FIELD NUMBER, FIELD LENGTH]@f[FORM NUMBER, FIELD NUMBER, FIELD LENGTH]...
.form trailerTEXT
.end
In this syntax example, the brackets are required; optional parameters are shown in italics.


Usage
The export command must be preceded in a script by a list records command that specifies the source table and the fields to be exported. The numeric parameters included in the export command refer to the sequential listing of the form(s) and field(s) included in the preceding list records command.
The export command lets you include the following formatting commands: .form header, .items, .form trailer, and .end. Items listed under the .form header, .form trailer, and .end commands print only once in the output file DataEase generates. Items listed under the .items formatting command, print multiple times, once for each record processed.
Example 1
for MEMBERS ;
list records
MEMBER ID in order ;
CARDNO. ;
TOTALDUE .
end
export to "MEMBDATA.TXT" .
.form header
Member ID~ Card No.~ Total Due
.items
@f[1,1]~ @f[1,2]~ @f[1,3]
.end

This example generates a variable length delimited ASCII file. Each record begins on a new line and each field value is separated by a tilde (~) character.
This example tells DataEase: (1) process all the MEMBERS records, listing the MEMBER ID in order, the credit CARD NO., and the total membership dues, (2) export the same data to a file called MEMBDATA.TXT, (3) include a header record in the export file that lists the column names.

Example 2
for MEMBERS ;
list records
LAST NAME .
for RESERVATIONS
list records
TOTALDUE .
end
end
export to "a: \MEMTOTAL.TXT" .
.form header members .items
.form header reservations
@f[1,1]~ @f[2,1]
.end

This example tells DataEase to: (1) process all the records in the MEMBERS table, listing the LAST NAME of each member, (2) for each MEMBERS record processed, list the TOTAL DUE value from all the related RESERVATIONS records, and (3) export the data to a variable length delimited ASCII file called MEMTOTAL.TXT located on disk drive "A". The syntax @f[2,1] refers to form 2 (RESERVATIONS), field 1 (TOTAL DUE).
Example 3
for MEMBERS ;
list records
MEMBERID in order ;
CARDNO. ;
TOTALDUE .
end
export to "MEMBDATA.TXT" .
.form header
.items
@f[1,1,5]@f[1,2,20]@f[1,3,7]
.end

This example generates a fixed length ASCII file and includes the same data as in Example 1.
The third digit in the field specification indicates the length of the field.