After fileerase, file names disappear from directory but show up in the Window menu

This code snippet:

openfile "SubDiv " + pattern(I,"##")
window FileName1 + " removed"
importdatabase "SubDiv " + pattern(I,"##")
fileerase "SubDiv " + pattern(I,"##") + ".pandb"

removes the deleted file names from the directory but the files are visible and open with the name id followed by " - Locked". I can close each one and it disappears.

What’s happening?

The database is still open in RAM. It’s locked because there is no longer any file to save it to.

I would recommend that you not delete a file while it is open – close it first.

Right - I had to open it so that I could import it, then should have closed it again.