Hello,
I would be very grateful for some help from the VBA I/O-experienced on this forum.
I'm writing an application to do some conversion on log file timestamps. I have it mostly completed, but am stuck on one issue: These files are text files which could have come from Windows/DOS or UNIX.
I am reading them using sequential access (Open filename for Input as #n, etc)
If they are Windows, it is pretty straightforward:- text file lines are terminated by CR/LF (or vbCrlf) and Excel reads them fine, splitting up neatly into records
If they are from UNIX, then I have a problem. - The records are terminated just with an LF which VBA does not recognize as a terminator, So it reads the whole file in as one humongous record.
Now this is okay. In the UNIX streams I can replace the LFs with CR/LFs and write out the file using binary I/O. It works.
Heres my problem: I don't know in advance whether a file is going to be UNIX or DOS format. And what I'm looking for is the most neat/effective way to determine this.
I can do something like count the records, and if there are more than one, conclude that it is a DOS file. But that seems clumsy, and these files are pretty big. The first one I tested was UNIX and gave me one string of length 800,000+ .
Any suggestiobns/solutions?
Cheers and many thanks in advance
For completeness, here's my code for the UnIX to DOS conversion:
Bookmarks