Closing mapped files
Closing mapped files
I am playing around with ddb, and I have encountered the situation where I can open a database, but then I cannot save the workspace, because it says that it cannot save with mapped files open. I have handles to the databases in a namespace with a function that will open them up automatically when I want, so I don't even want to save these newly created variables. How do I close out and get rid of all these databases so that I can save the workspace and close without removing the files?
Re: Closing mapped files
Mapped files: Before you can save, you need to remove all references to the mapped file:
If you're using the supplied ddb workspace, any "handles" contain references to the underlying mapped files. You must expunge such handles before trying to save the workspace. The following extract is from the Examples (http://dfns.dyalog.com/ddb_n_Examples.htm) variable in the workspace:
In this case, you'd need to ⎕EX'mytab' prior to saving the workspace.
Note that doing so removes only the handle, not the database itself.
Cheers,
John.
)clear
clear ws
vec ← 645 ¯1 ⎕MAP'/tmp/nfile' ⍝ "vec" is a reference to the mapped file
)save /tmp/myws.dws
Cannot perform operation with mapped files present.
vecvec ← 99 vec ⍝ "vecvec[2]" is a second ref
)save /tmp/myws.dws
Cannot perform operation with mapped files present.
⎕EX'vec' ⍝ removing first ref
)save /tmp/myws.dws
Cannot perform operation with mapped files present.
vecvec[2] ← 0 ⍝ removing second ref
)save /tmp/myws.dws
\tmp\myws saved Sat Oct 20 08:35:56 2012
⍝ Hurrah!
If you're using the supplied ddb workspace, any "handles" contain references to the underlying mapped files. You must expunge such handles before trying to save the workspace. The following extract is from the Examples (http://dfns.dyalog.com/ddb_n_Examples.htm) variable in the workspace:
⍝ Use a _handle_ for better performance ---------------------------------------
mytab ← ddb.open 'mytab' ⍝ use handle for speed.
mytab ddb.get (62>mytab ddb.get 'age') 'name' ⍝ compound selection.
Mick Keith
In this case, you'd need to ⎕EX'mytab' prior to saving the workspace.
Note that doing so removes only the handle, not the database itself.
Cheers,
John.