IDtConsumer.Put

Syntax

Put(Values: Array);

Parameters

Values - two-dimensional values array, that has to be written in the data consumer.

Description

The Put method records values array into the data consumer.

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;

Begin

//Array of exported values

TextConsumer := New DtTextConsumer.Create;

TextConsumer.File := "c:\Data_Out.txt";

TextConsumer.WriteHeader := True;

TextConsumer.RowDelimiter := #13 + #10; //Carriage return + row transfer

TextConsumer.DelimitedColumnDelimiter := #9; //The TAB key

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 the Carriage return+Row transfer combination is used as a row delimiter, and Tabulation symbol - as a field delimiter. Into the first file row field names are written. Next the specified values array is exported into the file.

See also:

IDtConsumer