P
pete2586
I have a module for extracting data from text files, part of which is shown
below along with a small sample from one of the text files. It works fine
some of the time but frequently it does not correctly extract the information
(X, Y, Z, Size values) from the line starting "X *" while the similar code
for the rest of the data always seems to work. It is not a problem with the
text files as I have checked that the formatting is the same in all of them.
What kind of problems could be causing this?
Thank you
------------------------------------------------------------------------------------------------
Module extract:
Do While Not EOF(1)
Line Input #1, CurrLnTxt
If CurrLnTxt Like "OFFSET" Or CurrLnTxt Like "RADIUS" Or CurrLnTxt Like
"CORRECT" Or CurrLnTxt Like "CYCLE" Or _
CurrLnTxt Like "TIME" Or CurrLnTxt Like "MAIN" Or CurrLnTxt Like
"*LIFE EXPIRED" Then GoTo loop_next
If CurrLnTxt Like "M-*" Then
rcs1.AddNew
rcs1!Machine = rcs0!Machine
rcs1!FilePath = rcs0!file_name
rcs1(1) = Left(CurrLnTxt, 13)
rcs1.Update
GoTo loop_next
End If
If CurrLnTxt Like " PART*" Then
rcs1.MoveLast
rcs1.Edit
rcs1(2) = (Right(Left(CurrLnTxt, 25), 4))
Dotpos = InStr(1, CurrLnTxt, ".")
Hr = Mid(CurrLnTxt, Dotpos - 2, 2)
Min = Mid(CurrLnTxt, Dotpos + 1, 2)
d = Right(Left(CurrLnTxt, 34), 2)
mth = Right(Left(CurrLnTxt, 38), 2)
yr = Right(Left(CurrLnTxt, 44), 4)
datev = d & "/" & mth & "/" & yr 'Date literal
datecheck = IsDate(datev)
If datecheck = False Then GoTo Date_error_continue
rcs1(3) = CDate(datev)
If Hr = " " Then
Hr = "00"
End If
If Min = " " Then
Min = "00"
End If
timev = Hr & ":" & Min & ":00" 'Time literal
rcs1(4) = CDate(timev)
rcs1.Update
GoTo loop_next
End If
Date_error_continue:
If CurrLnTxt Like "FEATURE *" Then
rcs.AddNew
rcs!PartID = rcs1!PartID
rcs(1) = Right(Left(CurrLnTxt, 11), 2)
rcs.Update
GoTo loop_next
End If
If CurrLnTxt Like "X *" Then
rcs.MoveLast
rcs.Edit
rcs(2) = Right(Left(CurrLnTxt, 13), 8)
rcs(3) = Right(Left(CurrLnTxt, 29), 8)
rcs(4) = Right(Left(CurrLnTxt, 45), 8)
rcs(5) = Right(Left(CurrLnTxt, 61), 6)
rcs.Update
GoTo loop_next
End If
If CurrLnTxt Like "FINISH" Then
ii = ii + 1
End If
------------------------------------------------------------------------------------------------
Text file extract:
CYCLE
TIME .103 HRS
M- 2008- 1010 PART 159T 1822 27 2
---------- --------- ---------- --------- ---------- ---------
PART 160 27 2 2006 18.22
---------- --------- ---------- --------- ---------- ---------
FEATURE 2
0FFSET 1
MAIN SPINDLE EXTERNAL ROUGH TURN
X .013 Y .002 Z .200 SIZE 44.616
OLD WEAR OFFSET X .053 Y .000 Z .015 R .000
NEW WEAR OFFSET X .037 Y .000 Z .015 R .000
FEATURE CORRECT
---------- --------- ---------- --------- ---------- ---------
FEATURE 3
0FFSET 3
MAIN SPINDLE INTERNAL ROUGH TURN
X - .005 Y - .001 Z - 8.444 SIZE 28.753
OLD WEAR OFFSET X - .003 Y .000 Z - .244 R .000
NEW WEAR OFFSET X - .026 Y .000 Z - .250 R .000
FEATURE CORRECT
---------- --------- ---------- --------- ---------- ---------
FEATURE 6
0FFSET 10
MAIN SPINDLE INTERNAL FINISH TURN
X - .014 Y - .008 Z - 8.498 SIZE 29.037
OLD WEAR OFFSET X - .019 Y .000 Z .027 R .000
NEW WEAR OFFSET X - .026 Y .000 Z .027 R .000
etc...
below along with a small sample from one of the text files. It works fine
some of the time but frequently it does not correctly extract the information
(X, Y, Z, Size values) from the line starting "X *" while the similar code
for the rest of the data always seems to work. It is not a problem with the
text files as I have checked that the formatting is the same in all of them.
What kind of problems could be causing this?
Thank you
------------------------------------------------------------------------------------------------
Module extract:
Do While Not EOF(1)
Line Input #1, CurrLnTxt
If CurrLnTxt Like "OFFSET" Or CurrLnTxt Like "RADIUS" Or CurrLnTxt Like
"CORRECT" Or CurrLnTxt Like "CYCLE" Or _
CurrLnTxt Like "TIME" Or CurrLnTxt Like "MAIN" Or CurrLnTxt Like
"*LIFE EXPIRED" Then GoTo loop_next
If CurrLnTxt Like "M-*" Then
rcs1.AddNew
rcs1!Machine = rcs0!Machine
rcs1!FilePath = rcs0!file_name
rcs1(1) = Left(CurrLnTxt, 13)
rcs1.Update
GoTo loop_next
End If
If CurrLnTxt Like " PART*" Then
rcs1.MoveLast
rcs1.Edit
rcs1(2) = (Right(Left(CurrLnTxt, 25), 4))
Dotpos = InStr(1, CurrLnTxt, ".")
Hr = Mid(CurrLnTxt, Dotpos - 2, 2)
Min = Mid(CurrLnTxt, Dotpos + 1, 2)
d = Right(Left(CurrLnTxt, 34), 2)
mth = Right(Left(CurrLnTxt, 38), 2)
yr = Right(Left(CurrLnTxt, 44), 4)
datev = d & "/" & mth & "/" & yr 'Date literal
datecheck = IsDate(datev)
If datecheck = False Then GoTo Date_error_continue
rcs1(3) = CDate(datev)
If Hr = " " Then
Hr = "00"
End If
If Min = " " Then
Min = "00"
End If
timev = Hr & ":" & Min & ":00" 'Time literal
rcs1(4) = CDate(timev)
rcs1.Update
GoTo loop_next
End If
Date_error_continue:
If CurrLnTxt Like "FEATURE *" Then
rcs.AddNew
rcs!PartID = rcs1!PartID
rcs(1) = Right(Left(CurrLnTxt, 11), 2)
rcs.Update
GoTo loop_next
End If
If CurrLnTxt Like "X *" Then
rcs.MoveLast
rcs.Edit
rcs(2) = Right(Left(CurrLnTxt, 13), 8)
rcs(3) = Right(Left(CurrLnTxt, 29), 8)
rcs(4) = Right(Left(CurrLnTxt, 45), 8)
rcs(5) = Right(Left(CurrLnTxt, 61), 6)
rcs.Update
GoTo loop_next
End If
If CurrLnTxt Like "FINISH" Then
ii = ii + 1
End If
------------------------------------------------------------------------------------------------
Text file extract:
CYCLE
TIME .103 HRS
M- 2008- 1010 PART 159T 1822 27 2
---------- --------- ---------- --------- ---------- ---------
PART 160 27 2 2006 18.22
---------- --------- ---------- --------- ---------- ---------
FEATURE 2
0FFSET 1
MAIN SPINDLE EXTERNAL ROUGH TURN
X .013 Y .002 Z .200 SIZE 44.616
OLD WEAR OFFSET X .053 Y .000 Z .015 R .000
NEW WEAR OFFSET X .037 Y .000 Z .015 R .000
FEATURE CORRECT
---------- --------- ---------- --------- ---------- ---------
FEATURE 3
0FFSET 3
MAIN SPINDLE INTERNAL ROUGH TURN
X - .005 Y - .001 Z - 8.444 SIZE 28.753
OLD WEAR OFFSET X - .003 Y .000 Z - .244 R .000
NEW WEAR OFFSET X - .026 Y .000 Z - .250 R .000
FEATURE CORRECT
---------- --------- ---------- --------- ---------- ---------
FEATURE 6
0FFSET 10
MAIN SPINDLE INTERNAL FINISH TURN
X - .014 Y - .008 Z - 8.498 SIZE 29.037
OLD WEAR OFFSET X - .019 Y .000 Z .027 R .000
NEW WEAR OFFSET X - .026 Y .000 Z .027 R .000
etc...