02-26-2024, 04:20 AM
(This post was last modified: 02-26-2024, 04:22 AM by PhilOfPerth.)
Another simple one:
What's the best way to skip a data item when searching a file? (the number of items is not known, and the item lengths are varied).
For example, to skip an item and jump to a GetData line in this listing:
MyFile$="MyFile"
Open MyFile$ For Input As #1
' put GetData: here?
While Not EOF(1)
' or GetData: here?
Input #1, data$
If Len(data$) <> 5 Then
GoTo GetData
else
DealWithIt
End If
' or GetData: here
Wend
Close
Forgetting our "phobias" about GoTo for now,
If the GetData point is before the While statement, will this create another loop, and leave the first one unresolved?
If it's just after the While statement, does whe While restart input at the beginning of the file?
Is the position just before the Wend the correct place?
What's the best way to skip a data item when searching a file? (the number of items is not known, and the item lengths are varied).
For example, to skip an item and jump to a GetData line in this listing:
MyFile$="MyFile"
Open MyFile$ For Input As #1
' put GetData: here?
While Not EOF(1)
' or GetData: here?
Input #1, data$
If Len(data$) <> 5 Then
GoTo GetData
else
DealWithIt
End If
' or GetData: here
Wend
Close
Forgetting our "phobias" about GoTo for now,
If the GetData point is before the While statement, will this create another loop, and leave the first one unresolved?
If it's just after the While statement, does whe While restart input at the beginning of the file?
Is the position just before the Wend the correct place?
Of all the places on Earth, and all the planets in the Universe, I'd rather live here (Perth, Western Australia.) 
Please visit my Website at: http://oldendayskids.blogspot.com/

Please visit my Website at: http://oldendayskids.blogspot.com/