1.3 Positional

- Positional field recognition vs. field delimiters.
- OnRecord context method implementation.
- VBScript function Mid used to Retrieve field values by position.
- Initialize dates and numerics from text values using the InitDate and InitNumeric functions.

location:  InstallDir/Samples/TextConverter/Manual Mode/1 Well formed input/

project file:  InstallDir/Samples/TextConverter/Manual Mode/1 Well formed input/1.3 Positional.ConverterX

Open "1.3 Positional.ConverterX" project file by pressing Open () on the  tool bar button or by selecting "Open Project" from "File" menu.

The input file does not have any field delimiters.  Each field starts from a position that remains constant throughout the file. The Input dictionary is set up using the field delimiters and shows just a single input field, which will hold data for the entire input record. After the output dictionary is set up (field names, types and widths) you can implement the OnRecord context method to extract the appropriate (position based) input values for each output term see the script pane. To help gather the positional information, tabular input view shows the position for each character in the input text if the cursor is held over that character for more than a second:

Using this information, you implement a custom conversion for each output field:

DictOut.SellerServNo.value = Mid(DictIn.Field.value, 5, 6)
DictOut.ContractNo.value = Mid(DictIn.Field.value, 11, 10)
DictOut.GroupNumber.value = Mid(DictIn.Field.value, 21, 7)

Use the InitDate, InitNumeric utility functions to initialize dates and numbers from the text values.

DictOut.NetYield.value = target.InitNumeric( Mid(DictIn.Field.value, 35, 5 ), 3 )
DictOut.DeliveryDate.value = target.InitDate( Mid(DictIn.Field.value, 103, 6 ), "MMDDYYY" )

To reduce the amount of typing, drag and drop fields from the output dictionary into the Script editor:

Each change in the script is immediatly reflected in the output preview, which make it easy to create a custom conversion quickly and without errors.
Set up the output database table and click Run () to start the conversion.

Go to Sample 2.1 for more training.

Sample 1.3

Drag and Drop VB Script

Go to 2.1 TagSearch for more training.

Related Sections

TextConverter's Concept

Setting up a Conversion: Step-by-Step

Samples and Walkthroughs

User Interface