Question: why .mla file remain locked open when using it?

I noticed the following. I have 2 worksheets. A.mw and B.mw.  From A.mw, it does something as follows

libname := currentdir(), libname
foo();

Where foo() is entry inside my say TMP.mla in currentdir(). This works fine with no problems and foo() executes and complete OK.

Now I make changes to the code foo.mpl, and need to update TMP.mla. currently I use LibraryTools. But i'd like to delete TMP.mla each time and create new one so I am sure there is no problem. So from B.mw I run this code

libname:= currentdir(),libname;
FileTools:-Remove("TMP.mla");
LibraryTools:-Create("TMP.mla");
read "foo.mpl";
LibraryTools:-Save('foo',"TMP.mla");

This all works well, except it fails at the Remove line, since "TMP.mla" could not be removed, since it was open before when running the A workseet, and it seems to be still open and Maple could not delete the file.

So each time this happens, I close all worksheets, close Maple, open Maple again, and now I can run the above code OK to update the mla.

Is there a better way to do all of this?

I worry if I do not delete the mla each time, I could end up with old code there I do not want, if I rename things in my code. That is why I like to start with fresh mla file each time.  But I always have to restart Maple now to update the mla.

 

Please Wait...