TEXT File Processing

Simple question may be for many people out here.

I am processing a text file in VB, lot of fields in each record(line).
I have to generate multiple out put files from each record, in different formats, which is a common requirement in many cases I guess. In order to format them, I am calling different procedures from the main procedure. My question is how to handle errors in each of the procedures. What I want is, If there is an error in any one of the procedures, I have to be able to write the source record to an error file and be able to jump to the next record . I am familiar with Resume Next, that only sends the control to the next line in the code, I do not want that, I want to end the whole processing for that line and go to process the next line.

I am able to do it with the help of goto lable usage.

I am just wondering if there are other better standards. I don't program in VB that often, that is why, I am seeking some advise in this area.

Any suggestions are greatly appreciated.

Thx,
srishan :D
[1075 byte] By [srishan] at [2007-11-18 2:11:49]
# 1 Re: TEXT File Processing
Set up an outer loop, which will read each line of your input file.

Set up an inner loop, which will go through your list of output files and send the info out in its required format.

In this inner loop, if you encounter an error, then set an error flag on, and then use EXIT DO (or EXIT FOR) statement to get out of the inner loop.

Immediately following the inner loop, check for your error flag, and if yes, then write to your error file.

Dave
zipperboy at 2007-11-10 0:02:42 >
# 2 Re: TEXT File Processing
Thx Dave. We always do it in PL/SQL(nested loops with nested expception handlers). Can you send me a sample code for this.
I think I like this better than what I was doing. I knew that goto label way is crude. What I am trying to understand from what you said is, the OUTER loop is the for the file, what is the inner loop based on?

Thanks,

srishan
srishan at 2007-11-10 0:03:36 >
# 3 Re: TEXT File Processing
The inner loop would be to generate your output files in the different formats that you said you wanted.

So, let's say you want to output to ordinary text, Rich Text, Word and Wordperfect formats, this is how I'd do it:

Open "C:\Inputfile.txt" for Input as #1
Open "C:\OutputFile.txt" for Output as #2
Open "C:\OutputFile.rtf" for Output as #3
Open "C:\OutputFile.doc" for Output as #4
Open "C:\OutputFile.wpd" for Output as #5

Do While Not EOF(1)
Line Input #1, LineRead
ErrorFlag = False

For I = 1 to 4
Select Case I
Case 1
Call WriteTextFile(ErrorFlag)
Case 2
Call WriteRTFFile(ErrorFlag)
Case 3
Call WriteWordFile(ErrorFlag)
Case 4
Call WriteWordPerfectFile(ErrorFlag)
End Select
If ErrorFlag Then
Exit For
End If
Next I

If ErrorFlag Then
Call WriteErrorFile
'If you now want to stop writing the rest of the file, use the next line
Exit Loop
End If

Loop

Close
zipperboy at 2007-11-10 0:04:38 >