Aladar,
You can achieve this by "attaching" your own MapBasic procedure to the menu item Save Workspace.
When you do so you can store the name of the latest workspace in a modular variable.
Have a look at this example:
'***************************************************************
Include "MapBasic.def"
Include "Menu.def"
Declare Sub Main
Declare Sub EndProgram
Declare Sub EndHandler
Declare Sub MENUSaveWorkspace
'**The modular variable to hold the name of the latest saved workspace
Dim msCurrentWorkspace As String
'----------------------------
Sub Main
'**Setting Save Workspace to use my own procedure for this
Alter Menu Item M_FILE_SAVE_WORKSPACE
Calling MENUSaveWorkspace
End Sub
'----------------------------
Sub EndHandler
'**Undoing my change to avoid breaking MapInfo when my application ends
Alter Menu Item MENUSaveWorkspace
Calling M_FILE_SAVE_WORKSPACE
End Sub
'----------------------------
Sub MENUSaveWorkspace
Dim sPath, sFile As String
If msCurrentWorkspace <> "" Then
sPath = PathToDirectory$(msCurrentWorkspace)
sFile = PathToFileName$(msCurrentWorkspace)
End If
'**Asking the user to pick a place and file for the workspace
sFile = FileSaveAsDlg(sPath, sFile, "WOR", "Save current workspace as ... (Custom)")
If sFile = "" Then
Exit Sub
End If
'**Storing the latest saved workspace in a modular variable
msCurrentWorkspace = sFile
'**Saving the current workspace
Run Command "Save Workspace As " & Chr$(34) & msCurrentWorkspace & Chr$(34)
End Sub
'***************************************************************
You can extend this so that you also create your own procedure for opening workspaces and so catching that name as well.
But I doubt you can catch everything. The user could open a workspace from the list of most recent files, and that would be stored.
And the Open dialog allows users to open any type of files, including workspace. That dialog could be tricky to create on your own.
Someone showed that you could look in the list of mos recent files and in that way get the name of the latest workspace.
Have a look at this thread:
Peter Horsbøll Møller
Pitney Bowes Business Insight - MapInfo