KILL (".\RisultatiQB64\*.*") cancel:
PRINT "Close the file opened and press a key.":
SLEEP RMDIR (".\RisultatiQB64")
BOH...
The program creates many files as a result of the calculations, in the directory ".\RisultatiQB64". Between these files, there is "C.IdrogrammiUnitari.csv"
So, in line 3, if "C.IdrogrammiUnitari.csv" doesn't exist, the program go to the line 11 and it deletes the directory ".\RisultatiQB64" because it is empty.
If "C.IdrogrammiUnitari.csv" exists, the program go to line 4 and 5, where it deletes all the files in the directory, then it EXIT DO, and it goes to line 11, and it deletes the directory ".\RisultatiQB64" because it is empty.
If, in the directory, there is a file opened (for example in Excel), line 5 gives an error, so, thank's to the line 1, the program, ON ERROR, goes to "cancel:", where it says to the user to close the file, and press a key. Pressing the key, the program loops.
But at this second time, if I DON'T close the file, the program , at line 5, rather then go (ON ERROR) to "cancel:", as intended, it crashes, as if ON ERROR command of line 1, was not in force. ON ERROR GOTO 0 is outside.
Why at the second loop the program doesn't go ON ERROR to "cancel:"??