IDtTextProviderField.FixedStartPosition

Syntax

FixedStartPosition: Integer;

Description

The FixedStartPosition property determines start 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.

Example

Executing the example requires that the repository contains an ETL task with the Etl identifier, and the text file Data.txt in the disk C root directory.Data in the file is located in fixed positions.

Sub Main;

Var

MB: IMetabase;

MObj: IMetabaseObject;

EtlTask: IEtlTask;

EtlProvider: IEtlPlainDataProvider;

TextProvider: IDtTextProvider;

Fields: IDtFieldDefinitions;

Field: IDtTextProviderField;

WxProvider: IWxRectangle;

WxETLProvider: IWxETLObject;

v: Array;

i: Integer;

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 Import From Text object creation

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 + row transfer

TextProvider.RangeHasHeader := True;

//Fixed length fields setting

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 provider

EtlProvider.Save;

//End of 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 Main;

After executing the example the Import from text object is created in the ETL task. The provider imports data from the Data.txt text file. During import 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 imported from the first file row.

See also:

IDtTextProviderField