| Class TAsciiFile (unit Ascifile) |
TComponent
| Constructors |
constructor Create(AOwner: TComponent);| Functions |
Procedure Execute;This is the only method of TAsciiFile.
Function ConvertStr(fieldstr: String): String;
Procedure CreateCSVFile;
Procedure CreateFixedFile;
Procedure WriteCSVField(Field : TField;Var FirstField : boolean);
Procedure WriteCSVHeader;function} (* This procedure creates the header-line containing the names of the columns.
Procedure WriteFixedField(Field : TField);
Procedure WriteFixedHeader;| Properties |
property Conversion : TConversion
property DataSource : TDataSource
property FileName : string
property FileType : TFileType
property Headers : boolean
property QuoteAll : boolean
property Separator : Char| Events |
| Variables |
FAscii : TextFile;
FConversion : TConversion;
FDataSource : TDataSource;
FFileName : string;
FFileType : TFileType;
FHeaders : boolean;
FQuoteAll : boolean;
FSeparator : Char;| Constructors |
constructor Create(AOwner: TComponent);The constructor sets up the defaults for the properties. I decided to use a constructor, in order for anybody to set their own defaults for the properties
| Functions |
Procedure Execute;Public declarations
This is the only method of TAsciiFile. It creates the ascii file and then calls either CreateCSVFile or CreateFixedFile. It then closes the ascii file.
Function ConvertStr(fieldstr: String): String;This function returns a string appropriately converted according to the Conversion field
Procedure CreateCSVFile;This procedure loops through the file and calls WriteCSVField for each field.
Procedure CreateFixedFile;CreateFixedFile just loops through the database and creats a line for each record.
Procedure WriteCSVField(Field : TField;Var FirstField : boolean);This procedure creates the entries for the fields. String fields are enclosed in double quotes. Numeric fields are not enclosed in double quotes, unless the QuoteAll propery is True. The following field types are not supported - TBytesField,TVarBytesField,TBlobField, TMemoField,TGraphicField. These fields will cause an "Invalid Field" entry to appear in the file.
Procedure WriteCSVHeader;Protected declarations
function} (* This procedure creates the header-line containing the names of the columns. All names are enclosed in double quotes
Procedure WriteFixedField(Field : TField);WriteFixedField uses PadString to create padded & justified strings to write to the file.
Procedure WriteFixedHeader;WriteFixedHeader writes the names of the fields in the first line of the output file.
| Properties |
property Conversion : TConversion
property DataSource : TDataSource
property FileName : string
property FileType : TFileTypePublished declarations
property Headers : boolean
property QuoteAll : boolean
property Separator : Char| Events |
| Variables |
FAscii : TextFile;
FConversion : TConversion;
FDataSource : TDataSource;
FFileName : string;
FFileType : TFileType;Private declarations
FHeaders : boolean;
FQuoteAll : boolean;
FSeparator : Char;