Parsing file in DTS Package

  • I have to parse the following lines. I need a detailed explanation of how the functions and operators are working together to find the dates. First time with VB.

    [HIGHLIGHT]

    LOT!99!AA!!999999!19990101!!!!!19990102

    LOT!01!AA!!999998!19990101!!!!!19990102

    LOT!03!AA!!999997!19990101!!!!!19990102

    LOT!99!AA!!999996!19990101!!!!!19990101

    SAD!99!AA!!999995!19990101!!!!!19990101[/HIGHLIGHT]

    ''''''''''''""""""""""""""""""""""""""Open the Modified LOT for reading""""""""""""""""""""""""""""""""""""""""""""""""

    Function Parse(c_strLOTFile)

    strMsg = "Opening LOT data file for reading."

    AddFileLogLine strMsg

    'reads text file line by line

    Do Until LOTFileOpen.AtEndOfStream

    strTemp = LOTFileOpen.ReadLine

    Const c_strLOT = "LOT"

    ''''''''''"""""""""""""""""""""""""""""" LOT Line """"""""""""""""""""""""""""""""""""""""""""""""

    Dim strDelim'Character used as delimiter

    Dim strTOWNo'TOW Number

    Dim dteLOTDate'LOT Date

    Dim dteTOWDate'TOW Date

    Dim strLOTLoc01'LOT01 location

    Dim strLOTLoc02'LOT02 location

    Dim strLOTLoc03'LOT03 location

    Dim strLOTLoc04'LOT04 location

    Dim strLOTLoc05'LOT05 location

    Dim strLOTLoc06'LOT06 location

    Dim strLOTLoc07'LOT07 location

    Dim strLOTLoc08'LOT08 location

    Dim strLOTLoc09'LOT09 location

    Dim dblcount

    dblcount = Null

    dblcount = 1

    'Set delimiter to !

    strDelim = "!"

    Case (Left(strTemp, 3) = c_strLOT) 'Start of Beginning Segment for LOT

    'Resets values to Null

    strTOWNo = Null

    dteLOTDate = Null

    dteTOWDate = Null

    strLOTLoc01 = Null

    strLOTLoc02 = Null

    strLOTLoc03 = Null

    strLOTLoc04 = Null

    strLOTLoc05 = Null

    strLOTLoc06 = Null

    strLOTLoc07 = Null

    strLOTLoc08 = Null

    strLOTLoc09 = Null

    'find all delimiter locations

    strLOTLoc01 = Instr(strTemp, strDelim) + 1

    strLOTLoc02 = Instr(strLOTLoc01, strTemp, strDelim) + 1

    strLOTLoc03 = Instr(strLOTLoc02, strTemp, strDelim) + 1

    strLOTLoc04 = Instr(strLOTLoc03, strTemp, strDelim) + 1

    strLOTLoc05 = Instr(strLOTLoc04, strTemp, strDelim) + 1

    strLOTLoc06 = Instr(strLOTLoc05, strTemp, strDelim) + 1

    strLOTLoc07 = Instr(strLOTLoc06, strTemp, strDelim) + 1

    strLOTLoc08 = Instr(strLOTLoc07, strTemp, strDelim) + 1

    strLOTLoc09 = Instr(strLOTLoc08, strTemp, strDelim) + 1

    strTOWNo = Mid(strTemp, strLOTLoc03, 7)

    dteTOWDate = Trim(Mid(strTemp, (strLOTLoc04 + 4), 2) &"/"&Mid(strTemp, (strLOTLoc04 + 6), 2) &"/"&Mid(strTemp, strLOTLoc04, 4))

    dteLOTDate = Trim(Mid(strTemp, (strLOTLoc09 + 4), 2) &"/"&Mid(strTemp, (strLOTLoc09 + 6), 2) &"/"&Mid(strTemp, strLOTLoc09, 4))

    'running count of segments

    dblcount = (dblcount + 1)

    End Select

    Loop

Viewing 0 posts

You must be logged in to reply to this topic. Login to reply