IMHO someone knowledgable could write an FLL which grabs that editor-handle and does a periodic saving.
Not necessary. You can save the command window content this way:
Code:
Local lcCommandHistoryDir, llSafety
lcCommandHistoryDir = Justpath(Sys(2005))
Try
llSafety = (Set("Safety")=="ON")
Set Safety Off
Copy File (lcCommandHistoryDir+"\_command.prg") To (lcCommandHistoryDir+"\_command.prg.bak")
Catch
If Empty(Sys(2005))
Messagebox("Without configuring a resource file no command history.",64,"No Command History")
Endif
Endtry
Show Window Command
Activate Window Command
Keyboard '{CTRL+A}'
Doevents
If Popup('ensurecopyworks')
Deactivate Popup ensurecopyworks
Endif
Define Popup ensurecopyworks Shortcut Relative
Define Bar _MED_COPY Of ensurecopyworks Prompt "\<Copy"
Activate Popup ensurecopyworks Nowait
Doevents
Keyboard '{CTRL+C}'
Doevents
Deactivate Popup ensurecopyworks
Strtofile(_Cliptext,lcCommandHistoryDir+"\_command.prg",0)
If llSafety
Set Safety On
EndIf
Why so complicated? Well, turns out after CTRL+A the copy menu item of the edit menu is grayed out (inactivated), so while CTRL+A did select all command window content, CTRL+C does not work to actually copy the selection into _cliptext. With the trick of defining a shortcut menu with the _MED_COPY system menu item you can trigger that with CTRL+C. It also requires all the Doevents.
Now to have that at hand at all times you could make it a menu item, add this as PRG to your project, do both or even put it into a timer, though that would disrupt working in the IDE when suddenly the command window is activated and the _cliptext changes to it.
One last important notice of caution: This is tested in my VFP IDE, if by any means any setting of VFP causes it not to work (or conditions like a closed command window - though I have Show Window, not only Activate Window) cause it to fail. Or any timing problems or flaky functionality of CTRL+C, the code does first backup _command.prg to _command.prg.bak. I ask you to verify that _command.prg is as you expect it to become before running it twice, otherwise that backup is overwritten by whatever is in the _cliptext instead of the command window content.
So in short: Please test this on your computer and inspect the effect on the _command.prg before putting this into production.
To verify it helps to add a last command or even just a comment into the command window and see if that gets into _command.prg (obviously it will only get into _command.prg.bak if you run this at least twice).
To verify _command.prg just do
Code:
Modify Command (JustPath(Sys(2005))+"\_command.prg")
One more notice: Once you verified _command.prg close that, otherwise you could get into the trap that closing the IDE saves the state of the prg you have open as a normal PRG edit window and not what's in the actual command window. Might not happen, as saving the command window should be done last and you didn't modify the verified _command.prg state, but you never know.
One idea verifying the copy step didn't fail is you check, whether _cliptext starts with _command.prg.bak and is longer than that backup. And/Or create a multi staging backup mechanism with bak1-bak9999 or whatever.