Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Continue a program after it gets an error... 1

Status
Not open for further replies.

brutteforcce

Technical User
Jun 23, 2006
105
RO
I have a list with the names of possible files that I want to work with. If it reaches at an inexistent file the program should do something and after that it should continue to the next files from the list. I don't know how can I make it go on after it returns an error because it didn't find a file.
 
Hi

Code:
  [b]const[/b] nrlis=3;
        lis:[b]array[/b][1..nrlis] [b]of[/b] string=([i]'first.txt'[/i],[i]'second.txt'[/i],[i]'third.txt'[/i]);
  [b]var[/b] fil:text;
      str:string;
      i:byte;
[b]begin[/b]
  i:=1;
  [b]while[/b] i<=nrlis [b]do begin[/b]
    write([i]'trying to read file '[/i],i,[i]' : '[/i],lis[i],[i]'... '[/i]);
    assign(fil,lis[i]);
    [green][b]{$I-}[/b][/green]
    reset(fil);
    [green][b]{$I+}[/b][/green]
    [b]case[/b] ioresult [b]of[/b]
      0:[b]begin[/b]
        close(fil);
        writeln([i]'Ok'[/i]);
        i:=nrlis;
      [b]end[/b];
      2:writeln([i]'File not found'[/i]);
      3:writeln([i]'Path not found'[/i]);
      [b]else[/b] writeln([i]'Error accured'[/i]);
    [b]end[/b];
    inc(i);
  [b]end[/b];
[b]end[/b].

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top