Undo, retry question

nate100

Member
With the following code I am trying to read an input file. If the input file has row1, I do not wish to process it:

/* why does undo mainloop, retry mainloop not work if within the input from */
def var cont_val as logical.
def var val1 as char.
def var val2 as char.
def var errval as int.

form
cont_val
with frame a.
mainloop:
repeat:

cont_val = no.
update cont_val with frame a.
if cont_val = false then next mainloop.

input from test.txt.

import delimiter "," val1.

display val1 .

if val1 = "row1" then do:
message "cannot process with field with row1 - back to mainloop". pause.
/* undo mainloop, leave mainloop. */ /* POINT A */
errval = 1.
end.


input close.
if errval > 0 then undo mainloop, leave mainloop. /* POINT B */
end.

why is it that if I put the undo mainloop, retry mainloop at POINT A, it does not work. But if I have it at PONT B, it works. It seems like it should work at either place. It seems like it is not working if within the input from but not sure why.

For the input file, I have the following in a text file:
row1
row2

Thanks and advance for the assistance .
 
before we get to your problem.. your logic may need correction. You only want to open the file once for input, then you need a repeat look to go through each line. Once its at the end of the file, it will leave the repeat loop and then you need to close the file.

Code:
     input from "filename".
     repeat:
       import linevariable.
    
     end.
     input close.

HTH
 
I believe the logic is correct. I have the main repeat but I do not need an inner repeat as I only want it to check the first record as such, I do not have another repeat.
 
Close input file before point A.
Code:
if val1 = "row1" then do:
[COLOR="#ff0000"]input close.[/COLOR]
message "cannot process with field with row1 - back to mainloop". pause. 
undo mainloop, retry mainloop. /* POINT A */
errval = 1.
end.
 
Back
Top