709-218-7927 The Landfall Garden House 60 Canon Bayley Road Bonavista, Newfoundland CANADA A0C 1B0 |
---|
(Home) Most-Recently Used (MRU) , What is Most-Recently Used? ; AutoSave and AuditSave , The Environment , Triggers , File Save Actions , File Close Actions , What About Third-Party Triggers? , Slave Functions , What about MRUse? , FileSaveAll, FileCloseAll, FileExit , The Set Of Procedures , lSaveAs , lClose , lFolderExists , lFileExists , lFileOverwrite , mFileSave , mFileSaveAs , mFileClose , FileSave , FileClose , FileSaveAs , FileSaveAll , FileCloseAll , DocumentClose , FileExit ,
Slave Functions
The slave or cover functions mSaveAs and mClose mimic Word’s raw functions. We channel our operations through these cover fucntions as good programming practice.
- (1) Our trigger intervention takes care of all “save before closing”, so mClose can always be a Document.Close(wdDoNotSaveChanges).
- (2) Our trigger intervention takes care of the existence of a folder or file with the same name, so mSave is always a Document.SaveAs.
- (3) Our Save operation can be implemented as a Document.SaveAs.
Pseudocode
What potential for error lies in these two functions?
As always, despite the best of interrogation (for the [non-]existence of a file, the user might effect an ill-times file operation (creating or deleting a file) that thwarts our devices. The low probability of this causes us to implement a very simple error trap that suggest that the user thwarted our automated operation. A typical example arises where
mSaveAs (Document, Fullname)
Document.Saveas(Fullname)
mClose (Document)
Document.Close(wdDoNotSaveChanges)
mFolderExists(Fullname)
If blnFolderExists(Fullname) thenLog (“Existing folder inhibited save” & Fullname)
mFolderExists=True
But how does the trigger code want to deal with this? For example, the sequence for File SaveAll may have debug/message box settings. The user may have elected to inhibit pop-up message boxes with errors, in which case we need to pass this information to the mFolderExists code.
Note that we ought to offer a tri-way result, perhaps -1,0,+1 to represent Yes, No and Cancel.
mFileExists(Fullname)
(as above)
mFileOverwrite(Fullname)
(as above)
mSaveAsAudit(Document)
It is the caller’s responsibility to manage the document’s original name, and to re-apply it wherever relevant and possible.
The Audit process creates a near-unique name from the current date and time and mSaveAs’s the document in a specified folder (probably Tools, Options, File locations, Autorecover files) with that name. The generated name is returned as the result of this function.
Do we test the very remote possibility that there exists a folder or file with this time-sensitive name? No, we do not. The test takes operating system time and it is likely to arise only if the user has played with the system clock and the mSaveAsAudit is coincident to within one hundredth of a second.
We institute a generic error trap and a suitable error message.
709-218-7927 CPRGreaves@gmail.com Bonavista, Saturday, April 27, 2024 8:07 AM Copyright © 1990-2024 Chris Greaves. All Rights Reserved. |
---|