IDtFieldDefinitions.Add

Syntax

Add: IDtFieldDefinition;

Description

The Add method adds a new data provider or consumer field and returns its description.

Example

Executing the example requires the Data_Out.txt file in the disk C root directory.

Sub Main;
Var
    TextConsumer: IDtTextConsumer;
    Fields: IDtFieldDefinitions;
    Field: IDtFieldDefinition;
    v: Array;
    RowCount: Integer = 1000;
Begin
    //Array of exported values
    v := New Variant[3, RowCount];
    v[00] := //Values...
    //Export in text file
    TextConsumer := New DtTextConsumer.Create;
    TextConsumer.File := "c:\Data_Out.txt";
    TextConsumer.WriteHeader := True;
    TextConsumer.RowDelimiter := #13 + #10; //Return carriage + transfer row
    TextConsumer.DelimitedColumnDelimiter := #9; //Button Tab
    Fields := TextConsumer.Fields;
    Field := Fields.Add;
    Field.DataType := DbDataType.String;
    Field.Name := "Name";
    Field := Fields.Add;
    Field.DataType := DbDataType.Integer;
    Field.Name := "Identifier";
    Field := Fields.Add;
    Field.DataType := DbDataType.Float;
    Field.Name := "Value";
    TextConsumer.Open;
    TextConsumer.Clear;
    TextConsumer.Put(v);
    TextConsumer.Close
End Sub Main;

After executing the example a new data consumer, that exports data in text file, is created. During export as a row delimiter combination Carriage return+Row transfer is used, as a field delimiter - tabulation symbol. Into the first file row field names are written. Next the specified values array is exported into the file.

See also:

IDtFieldDefinitions