Put(Values: Array);
Values. Two-dimensional array of values that should be written to data consumer.
The Put method records values array into the data consumer.
Executing the example requires that the root of the C disk contains the Data_Out.txt file.
Sub UserProc;
Var
TextConsumer: IDtTextConsumer;
Fields: IDtFieldDefinitions;
Field: IDtFieldDefinition;
v: Array[3, 4] =
[["Buckwheat", "Milk", "Sugar", "Bread"],
[10, 20, 30, 40],
[313.12, 301.53, 254.13, 404.11]];
Begin
// Data consumer
TextConsumer := New DtTextConsumer.Create;
TextConsumer.File := "C:\Data_Out.txt";
TextConsumer.WriteHeader := True;
TextConsumer.RowDelimiter := #13 + #10; //Return carriage + transfer row
TextConsumer.DelimitedColumnDelimiter := #9; //TAB key
// Data consumer fields
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";
// Data export
TextConsumer.Open;
TextConsumer.Clear;
TextConsumer.Put(v);
TextConsumer.Close
End Sub UserProc;
After executing the example a new data consumer that exports data in text file is created. During export the Carriage Return+Line Feed combination is used as a row delimiter, and Tabulation symbol - as a field delimiter. Row field names are written to the first file row. Then the specified values array is exported into the file.
See also: