I'm a VB newbie with a COBOL background, and I see that a VB Structure is a way to simulate a COBOL FD (record layout of fields).
I am working on a program to use a loop to read an input textfile one record at a time, process certain fields in the record, and write out the updated record to an output textfile (a second file) - a simple batch process. These are plain old text-editor type textfiles.
I understand that using StreamReader and StreamWriter is the preferred approach (as opposed to FileGet and FilePut).
Since StreamReader ReadLine and Streamwriter WriteLine simply use a single string variable for the whole record, what I want to do is to "map" that single string (representing the entire record as read by ReadLine) to a Structure, process the fields of the Structure, then "map" the Structure back to a single string for the WriteLine to write out.
(I know that FileGet and FilePut can read and write directly to / from structures, but I prefer to use StrearmReader/ReadLine and StreamWriter/WriteLine. I also know that I can do partial Reads and Writes, but don't want to).
What is the best (simplest, most efficient) way to do this "mapping" back and forth between a single string (representing the whole record) and the structure, while adhering to the spirit of the above approach?
Thanks
I am working on a program to use a loop to read an input textfile one record at a time, process certain fields in the record, and write out the updated record to an output textfile (a second file) - a simple batch process. These are plain old text-editor type textfiles.
I understand that using StreamReader and StreamWriter is the preferred approach (as opposed to FileGet and FilePut).
Since StreamReader ReadLine and Streamwriter WriteLine simply use a single string variable for the whole record, what I want to do is to "map" that single string (representing the entire record as read by ReadLine) to a Structure, process the fields of the Structure, then "map" the Structure back to a single string for the WriteLine to write out.
(I know that FileGet and FilePut can read and write directly to / from structures, but I prefer to use StrearmReader/ReadLine and StreamWriter/WriteLine. I also know that I can do partial Reads and Writes, but don't want to).
What is the best (simplest, most efficient) way to do this "mapping" back and forth between a single string (representing the whole record) and the structure, while adhering to the spirit of the above approach?
Thanks