'000000000011111111112222222222333333333344444444445555555555 position
'012345678901234567890123456789012345678901234567890123456789
'
'Bill Bloggs 123 Fourth Street Fifthville
'Dan Dubois 345 Fifth Road Sixthville
'Erel Eminent 567 Sixth Avenue Seventhville
'
'00000 11111111111 22222222222222222222 333333333333333333333 field number (NOTE NumFields = 4, not 3 ;-)
'5 11 20 21 field width
'======================================== minimum line length = 4 + (5 + 11 + 20) = 40
Dim MinLineLength As Int = NumFields 'preload with column-separating spaces and first character of last field
For FieldNumber = 0 to NumFields - 2
MinLineLength = MinLineLength + FieldLength(FieldNumber)
Next
For Each LineString in the file
Dim OkFlag As Boolean
OkFlag = (LineString.Length >= MinLineLength)
If OkFlag Then
Dim FieldPosition As Int = 0
For FieldNumber = 0 to NumFields - 1
If FieldNumber <> 0 Then
If LineString.CharAt(FieldPosition - 1) <> " " Then
OkFlag = False
Exit 'Exit For, since no need to check any further
End If
End If
If LineString.CharAt(FieldPosition) = " " Then
OkFlag = False
Exit 'Exit For, since no need to check any further
End If
FieldPosition = FieldPosition + FieldLength(FieldNumber) + 1
Next
End If
If OkFlag Then
CallYourOwnSplitLineRoutine() 'line looking good so far
Else
Log("Line failed filter test")
Log("[" & LineString & "]"
End If
Loop