General discussion

Locked

VB and embedded EOF characters

By TheViper ·
I have a text file that contains randomly distributed ASCII 26 characters that I want to process using a VB app.
VB sees ASCII 26 as EOF and will not process the file beyond the first EOF it hits.
I have no control over the file contents because the file is generated by a customer who is not responsive to requests that require programming changes.
The complete file can be loaded by text and word processors like Notepad, Textpad, Wordpad and Word.
Due to the random occurrence of the characters, I cannot use a macro based on consistent mouse movements and keystrokes. A Word VBA macro won't work because Word sees the original file as Unicode UTF-8 encoded and when the file is saved as plain text, Word eliminates other control characters (e.g. ASCII 12 page breaks) that must be retained.
Does anyone have any suggestions as to how I might resolve this dilemma within a VB app, even if it involves launching another app to clean the EOFs from the file?

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
Thread display: Collapse - | Expand +

All Comments

Collapse -

VB and embedded EOF characters

by Lo In reply to VB and embedded EOF chara ...

Hi - Been a while but ... Go into VB help and Find Open Statement. There is a file mode (type of open), Binary. This will give successive 'blocks' of the file and I believe will read until there is no more data associated with the file.

Problem with this is that any record definiton is lost, you just get N bytes of data. What it looks like, how it is delimted, etc is up to your applicaton to determine. I think some system call this 'streaming' or some such (just a string of bytes). When you read the last block, you will have to determine where the 'logical' end of data is. Not sure about the details of doing this. There are counters, functions, system calls, etc. that will provide the number of bytes in the file or the block.As I said, it's been some time since I played with this, and it was just playing to see if it worked in VB. I have dome same/similar with COBOL, FORTRAN, etc. on other OS for a real application (IBM tape from the Phone Company in EBCDIC converting to ASCII with IBM binary fields in the EBCDIC input, etc.)

Hope that helps, lo

Collapse -

VB and embedded EOF characters

by TheViper In reply to VB and embedded EOF chara ...

Poster rated this answer

Collapse -

VB and embedded EOF characters

by Bob Sellman In reply to VB and embedded EOF chara ...

It's also been a while for me, but this type of problem was routine with good old BASIC programs. The way to get around it was to open a file as a random access type file or whatever record length you decide you want to work with. Be sure to test for EOF (end of file) so you don't try to read past the end of the file.

When you work with the file as a random access, fixed record length file, the ASCII 26 character is read in a just another character.

You then read each "record" in and handle the ASCII 26 characters in whatever is appropriate for your situation. For example, you might just want to change them to spaces. Or you might just leave them alone.

Just concatenate the subsequent records until you find the end of what youconsider a record or data you need to extract.

I've found that reading data in using the fixed record length random access file format has solved many otherwise nightmarish data loading problems.

Collapse -

VB and embedded EOF characters

by TheViper In reply to VB and embedded EOF chara ...

Worked well.
When true EOF was encountered, the remainder of the record was null filled, so I just used the null character to indicate true EOF.

Thanks.

Collapse -

VB and embedded EOF characters

by TheViper In reply to VB and embedded EOF chara ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums