Folder := 'C:\Sales Import'; FileSystem.SETRANGE(FileSystem.Path, Folder); FileSystem.SETRANGE(FileSystem."Is a file", TRUE); FileSystem.SETFILTER(FileSystem.Name, '@*.txt'); IF FileSystem.FIND('-') THEN BEGIN REPEAT //MESSAGE(FileSystem.Name); old_name := ''; new_name := ''; file_name := FileSystem.Name; //for counting old_name := FileSystem.Path + '\' + FileSystem.Name; new_name := FileSystem.Path + '\' + file_name; //MESSAGE('%1',STRLEN(file_name)); file_to_import := FileSystem.Path + '\' + FileSystem.Name; IF STRLEN(file_name) = 19 THEN BEGIN //MESSAGE(FORMAT(STRLEN(file_name))); IF EXISTS(file_to_import) THEN BEGIN //MESSAGE(FileSystem.Name); IF FileSystem.Size <> 0 THEN BEGIN //CLEAR(DataportObject); //DataportObject.SetFileName(file_to_import); DataportObject.FILENAME(file_to_import); DataportObject.IMPORT(TRUE); DataportObject.RUNMODAL; [b] ///SKIP HERE ON ERROR <--------------[/b] END; //to rename in to new name RENAME(old_name, new_name); IF COPY(FileSystem.Path + '\' + FileSystem.Name, FileSystem.Path + '\Imported\' + FileSystem.Name) THEN //MESSAGE(old_name); ERASE(FileSystem.Path + '\' +FileSystem.Name); END; END; UNTIL FileSystem.NEXT = 0; END; MESSAGE('DONE');
Comments
Folder := 'C:\Sales Import\'
EDIT: sorry, I just realized that this is not the error
i dont know how to skip the textfile if it encounters any error
Instead of
Do something like this:
FD Consulting
i'd give you a scenario, if there was an error on textfile lets say:
!1!|!Sales!|!00A0000001!|!LOCAL!|!000100!|
But i insert instead
?!1!|!Sales!|!00A0000001!|!LOCAL!|!000100!|
we would a receive an error that it cant import.
On my code it has a loop, when getting an error like this it should skip that textfile
Nav will not throw any error message, and will continue executing the next command.
Just a happy frood who knows where his towel is