FixedLength: Integer;
The FixedLength property determines field length in symbols.
Executing the example requires the Data_Out.txt file in the disk C root directory.
Sub Main;
Var
MB: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlConsumer: IEtlPlainDataConsumer;
TextConsumer: IDtTextConsumer;
Fields: IDtFieldDefinitions;
Field: IDtTextConsumerField;
WxConsumer: IWxRectangle;
WxETLConsumer: IWxETLObject;
Begin
MB := MetabaseClass.Active;
//ETL task search. Repository object with the ETL identifier
MObj := MB.ItemById("Etl").Edit;
EtlTask := MObj As IEtlTask;
//Start of the provider creation
//The Export To Text object creation
EtlConsumer := EtlTask.Create(EtlObjectType.PlainDataTextConsumer) As IEtlPlainDataConsumer;
EtlConsumer := EtlConsumer.Edit;
EtlConsumer.Id := "Text_Consumer";
EtlConsumer.Name := "Export to text";
EtlConsumer.Description := "Export to text";
//Set up data provider
TextConsumer := EtlConsumer.Consumer As IDtTextConsumer;
TextConsumer.File := "c:\Data_Out.txt";
TextConsumer.FormatType := DtTextFormatType.Fixed;
TextConsumer.RowDelimiter := #13 + #10; //Carriage return + row transfer
TextConsumer.WriteHeader := True;
//Fixed length fields setting
Fields := TextConsumer.Fields;
Field := Fields.Add As IDtTextConsumerField;
Field.Name := "Field0";
Field.DataType := DbDataType.String;
Field.FixedLength := 15;
Field := Fields.Add As IDtTextConsumerField;
Field.Name := "Field1";
Field.DataType := DbDataType.String;
Field.FixedLength := 15;
Field := Fields.Add As IDtTextConsumerField;
Field.Name := "Field2";
Field.DataType := DbDataType.String;
Field.FixedLength := 15;
EtlConsumer.FillDefault;
//Save provider
EtlConsumer.Save;
//End of provider creation
//Start of visual object creation
WxConsumer := EtlTask.Workspace.CreateRectangle;
WxETLConsumer := New WxETLObject.Create;
WxETLConsumer.ETLObject := EtlConsumer;
WxConsumer.Style.TextPosition := WxTextPosition.Bottom;
WxConsumer.Style.PictureMarginTop := -10;
WxConsumer.PinPosition := New GxPointF.Create(50, 50);
WxConsumer.Extension := WxETLConsumer As IWxShapeExtension;
//End of visual object creation
//Save Etl task
MObj.Save;
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, fields structure is fixed. For one field 15 positions are allowed. Field names are exported in the first file row.
See also: