Step 7. Customize through scripting

Customization of conversion through scripting delivers a virtually unlimited flexibility (See scripting.)

Right click on a field in the output dictionary and follow the context menu down to select "Create Script Conversion" item, the OnRecord context method will be inserted with a line of code for the corresponding field customization:

'----------------- OnRecord -----------------

Function OnRecord

DictOut.Price10.value = Empty

End Function

We have discussed how scripting can facilitate record delimiter and field delimiter related tasks in Step 2 and Step 3 respectively.

Here we will talk about customized data transformation and output record filtering.

1. Customized data transformation can be very handy when your output field value should be a function of multiple input fields:

DictOut.FullName.value = DictInt.FirstName.value & " " & DictInt.LastName.value

It can also be useful if additional logic should be applied to the output value:

DictOut.Field1.value = Left( DictInt.Field1.value, 3 ) & "_" & Right( DictInt.Field1.value, 3 )

Output value modification through scripting overrides the default data transformation, which is defined by the field mapping.

2. Output record filtering is needed when your input data consists of multi level information or if it contains junk data. Scripting allows the disposal of unneeded records. Consider the following input sample:

872375762  VALVE GUIDE         10.25     8       82.00     19980523     19980723
897987237  VALVE SPRING         4.95     8       39.60     19980523     19980723
987987765  PISTON SET         805.00     2    1,610.00     19980523     19930913
SUBTOTAL ENGINE PARTS                     22    2,446.88         

Let's say we do not want to place the subtotal level information into the output database table.  The script accomplishing the task would be:

Function OnRecord
If Left( DictIn.Field_1.value, 3 ) = "SUB" Then this.SkipRecord()
End Function

Now we can proceed to Step 8 - Set the output database table.

(or go back to Step 6. Edit field map.)