Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - bryandj23

Pages: [1]
1
QB64 Discussion / Trapping "File Not Found" Errors
« on: June 25, 2020, 11:53:46 am »
Hey all.   Long time QB45 user, and jumping on the QB64 bandwagon like everyone else.

I'm trying to trap the 'file not found' error, and running into an issue upon subsequent error conditions.

Code: QB64: [Select]
  1. GetFileName:
  2. Line Input InFile$
  3. On Error GOTO NotFound
  4. Open InFile$ for INPUT AS #1
  5.  
  6. ...
  7.  
  8.  

then, NotFound:

Code: QB64: [Select]
  1. NotFound:
  2. COLOR 15: PRINT Infile$; " ";: COLOR 12: PRINT "Not Found!!"
  3. GOTO getfilename


This routine correct traps the first occurrence, however on second occurrence, the trap does not work and QB64 attempts to open a non-existent file and I get a pop-up error (assuming from the compiler).

I'm sure I'm missing something simple (like clearing the error state), but figured the 'ON ERROR GOTO 0" would handle it properly.

Thanks in advance.


Pages: [1]