IMPORT STREAM Query

Windows xp and Progress 9.1e CHUI

There are 20 lines in the file to be imported including 1 duplicated.
Hi,

Its Friday afternoon and am having problems with the following piece of code -

Firstly as their are duplicates in the imported file the ERROR-STATUS statement kicks in, which is fine, except I get the same messages displayed in the status field at the bottom of the screen.
'Doneone' says 19 created.

The second more worrying thing is if I unmask out the bit at the bottom of the program (labeled to redisplay ) then only 14 get created - the other 5 after the duplicate are ignored.

What am I missing (apart from the alcohol)

Mike


def var doneone as int no-undo.
def temp-table Tbook like book.
define STREAM instream.
STATUS INPUT OFF.
INPUT STREAM instream FROM "common\bookupdates.txt" NO-ECHO.
repeat:
CREATE Tbook.
IMPORT STREAM instream Tbook no-error.
if ERROR-STATUS:ERROR then DO:
message "Already have book in this file " skip
ERROR-STATUS:GET-MESSAGE(1)
view-as alert-box.

END.
else doneone = doneone + 1.
END.
INPUT STREAM instream CLOSE.
OUTPUT TO TERMINAL.
pause 0 no-message.
message "have created tbooks" doneone skip view-as alert-box.

/*
/* to redisplay */
for each Tbook:
message " Tbook" Tbook.bookcode isbn isbn13 shorttitle
view-as alert-box.
end.
*/
 

rusguy

Member
I think that when you have an error it leaves already created empty record, so no records after the duplicate one can be created. To fix this, try putting "undo, next" inside your error checking block
 

a.vermeulen

New Member
I always use for the reading part:
repeat:
do transaction:
CREATE Tbook.
IMPORT STREAM instream Tbook no-error.
doneone = doneone + 1.
end.
end.

The transaction mechanisme will keep your table and variables clean.

Regards,
Alexander Vermeulen
 
Top