IDtTextConsumerField.FixedLength

Syntax

FixedLength: Integer;

Description

The FixedLength property determines field length in symbols.

Example

Executing the example requires that the root of the C disk contains the Data_Out.txt file.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    EtlTask: IEtlTask;
    EtlConsumer: IEtlPlainDataConsumer;
    TextConsumer: IDtTextConsumer;
    Fields: IDtFieldDefinitions;
    Field: IDtTextConsumerField;
    WxConsumer: IWxRectangle;
    WxETLConsumer: IWxETLObject;
Begin
    MB := MetabaseClass.Active;
    // Search for ETL task. Repository object with the "ETL" identifier
    MObj := MB.ItemById("ETL").Edit;
    EtlTask := MObj As IEtlTask;
    // Start of data provider creation
    // Create the "Export to Text" object
    EtlConsumer := EtlTask.Create(EtlObjectType.PlainDataTextConsumer) As IEtlPlainDataConsumer;
    EtlConsumer := EtlConsumer.Edit;
    EtlConsumer.Id := "Text_Consumer";
    EtlConsumer.Name := "Export in text";
    EtlConsumer.Description := "Export in text";
    // Set up data provider
    TextConsumer := EtlConsumer.Consumer As IDtTextConsumer;
    TextConsumer.File := "c:\Data_Out.txt";
    TextConsumer.FormatType := DtTextFormatType.Fixed;
    TextConsumer.RowDelimiter := #13 + #10; //Return carriage + line feed
    TextConsumer.WriteHeader := True;
    // Set up fields with fixed length
    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 data provider
    EtlConsumer.Save;
    // End of data 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(5050);
    WxConsumer.Extension := WxETLConsumer As IWxShapeExtension;
    // End of visual object creation
    // Save ETL task
    MObj.Save;
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, fields structure is fixed. For one field 15 positions are allowed. Field names are exported in the first file row.

See also:

IDtTextConsumerField