FixedEndPosition: Integer;
The FixedEndPosition property determines end position in the file that limits data for the current field.
It is relevant if the FormatType property is set to the DtTextFormatType.Fixed value.
Executing the example requires that the repository contains an ETL task with the ETL identifier and the Data.txt file in the root of the C disk. Data in the file is located in fixed positions.
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlProvider: IEtlPlainDataProvider;
TextProvider: IDtTextProvider;
Fields: IDtFieldDefinitions;
Field: IDtTextProviderField;
WxProvider: IWxRectangle;
WxETLProvider: 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 data provider creation
// Create the "Import from Text" object
EtlProvider := EtlTask.Create(EtlObjectType.PlainDataTextProvider) As IEtlPlainDataProvider;
EtlProvider := EtlProvider.Edit;
EtlProvider.Id := "Text_Provider";
EtlProvider.Name := "Import from Text";
EtlProvider.Description := "Import from Text";
// Set up data provider
TextProvider := EtlProvider.Provider As IDtTextProvider;
TextProvider.File := "c:\Data.txt";
TextProvider.FormatType := DtTextFormatType.Fixed;
TextProvider.RowDelimiter := #13 + #10; //Carriage return + Line feed
TextProvider.RangeHasHeader := True;
// Set up fields with fixed length
Fields := TextProvider.Fields;
Field := Fields.Add As IDtTextProviderField;
Field.Name := "Field0";
Field.DataType := DbDataType.String;
Field.FixedStartPosition := 1;
Field.FixedEndPosition := 14;
Field := Fields.Add As IDtTextProviderField;
Field.Name := "Field1";
Field.DataType := DbDataType.String;
Field.FixedStartPosition := 15;
Field.FixedEndPosition := 29;
Field := Fields.Add As IDtTextProviderField;
Field.Name := "Field2";
Field.DataType := DbDataType.String;
Field.FixedStartPosition := 30;
Field.FixedEndPosition := 45;
EtlProvider.FillDefault;
// Save data provider
EtlProvider.Save;
// End of data provider creation
// Start of visual object creation
WxProvider := EtlTask.Workspace.CreateRectangle;
WxETLProvider := New WxETLObject.Create;
WxETLProvider.ETLObject := EtlProvider;
WxProvider.Style.TextPosition := WxTextPosition.Bottom;
WxProvider.Style.PictureMarginTop := -10;
WxProvider.PinPosition := New GxPointF.Create(50, 50);
WxProvider.Extension := WxETLProvider As IWxShapeExtension;
// End of visual object creation
// Save ETL task
MObj.Save;
End Sub UserProc;
After executing the example the Import from Text object is created in the ETL task. This data provider imports data from the specified text file. During import the Carriage Return+Line Feed combination is used as a row delimiter, fields structure is fixed. For one field 15 positions are allowed. Field names are imported from the first file row.
See also: