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 header
TEXT | FIELDNAME
.items
@f[FORM NUMBER, FIELD NUMBER, FIELD LENGTH]@f[FORM NUMBER,
FIELD NUMBER, FIELD LENGTH]...
.form trailer
TEXT
.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 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. These formatting commands function much like their counterparts in character-based versions of DataEase. 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 ;
CARD NO. ;
TOTAL DUE .
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
TOTAL DUE .
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
MEMBER ID in order ;
CARD NO. ;
TOTAL DUE .
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.
Use of Statistics with the DQL Export Command
The "Export from DQL" functionality has been enhanced in versions 5.12 and later, allowing the use of statistical operators
in an export query. Any of the statistics keywords - "sum", "count", "max", "min" etc, can now be inserted after the field number within the @f[] field specification of an export format. The statistic must also be specified in the query for the field. Formatting information for the statistic fields can be specified in the report layout, exactly as you would edit any other field.

Example 4
for Customer ;
list records
Customer No : item count ;
First Name ;
Last Name .
for Invoice
list records
Invoice No : item count ;
Invoice Total : item sum .
end
end
export to "c:\export1d.txt" .
.form header Customer
CustNo FName LName CustRunCount
.items Customer
@f[1,1] @f[1,2] @f[1,3] @f[1,1 count]
.form header Invoice
Invoice No InvTotal InvRunCount InvRunSum
.items Invoice
@f[2,1] @f[2,2] @f[2,1 count] @f[2,2 sum]
.form trailer Invoice
-----------------------------
InvRunCount - @f[2,1 count]
InvRunSum - @f[2,2 sum]
-----------------------------
.form trailer Customer
-----------------------------
CustRunCount - @f[1,1 count]
-----------------------------
.end

You should use this new functionality carefully. No error checking is carried out to verify that the
appropriate statistical operator has been used with a particular field - so you could, for example, try to 'sum' a text field, generating results of no worth, apart from a dubious amusement value.