CopyFileText

<< Click to Display Table of Contents >>

Navigation:  Apollo VCL Components > Apollo VCL Component Reference > TApolloTable > TApolloTable Methods >

CopyFileText

Declaration

function CopyFileText( sTextFileName : String;

iFileType : Integer ) : WordBool;

Description

Copy the current data table to an ASCII text file. The text file may be formatted as either comma delimited or SDF (system data format).

Comma Delimited

In a comma delimited file, each field is separated from the next with a comma, and all character fields have trailing spaces removed and are surrounded with quotes (").

Each text record is terminated with carriage return and line feed byte pair (CR-LF).

The records are of variable length.

System Data Format

SDF text files contain images of each data table record.

Each record is a fixed length (the data table record length - 1 for the deletion flag byte and plus 2 for the CR-LF pair).

There are no delimiters between fields.

Memo field references are blank in the text output file.

If a file with the same name exists, it is overwritten.

The progress of the function may be visually monitored if a gauge hook has been set via SetGaugeHook .

Parameters

sTextFileName: The name of the target text file including full path and extension if desired. An existing file with the same name will be overwritten.

image\tip.gif When working with a remote table via Apollo Database Server, you may only copy the text file into the same Database directory as the source table. The remote client cannot specify a physical server drive/path location and must use the defined server alias instead.  Any physical drive/path included in the sTextFileName parameter will be ignored for remote tables.

 

iFileType: Use one of the following manifest constants:

 COMMA_DELIM 21 Comma-Delimited Text File

 SDF_FILE 22 Space-Delimited (SDF) Text File

 TAB_DELIM 23 Tab delimited file

 SPACE_DELIM 24 Space delimited

iFileType Sample Results

COMMA_DELIM

"Homer","Simpson","41 Maiden Lane","Springfield"

SDF_FILE

Homer Simpson 41 Maiden Lane

TAB_DELIM

"Homer" "Simpson" "41 Maiden Lane"

SPACE_DELIM

"Homer " "Simpson " "41 Maiden Lane "

Return Value

True or False depending on the outcome of the operation.

Delphi Example

// Pass either COMMA_DELIM or SDF_FILE as parameter

procedure TForm1.ExportFileAs( iFileType : Integer );

var

 s : String; 

begin

 if SaveDialog1.Execute then 

 begin 

         s := SaveDialog1.FileName; 

         ApTbl.SetGaugeHook( self.Handle ); 

         ApTbl.CopyFileText( s, iFileType );

         ApTbl.SetGaugeHook( 0 ); 

         ProgressBar1.Position := 0; 

 end; 

end;

See Also

CopyFile , AppendFrom