Detect whether XY needs saving

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Detect whether XY needs saving

Post by klownboy »

I was working on a script which ask the question at the end whether the user would like to save settings, but I'd like not to ask the question if the user didn't make any changes (in this case to List management items which cover a number of different types of savesetting options). Obviously this would have to be based on the user having made no changes to XY prior to starting the script or a save being done prior to the running the script. Is there any current way to detect via scripting whether XY setting have changed and therefore need to be saved? Don of course senses changes and the button for save changes from green to brown, but can we do that in scripting? I may have missed something running through help file, but it might be a useful capability in scripting possibly via the SC get ("savesettings") and it would return a parameter for the setting that changed similar to the SC savesettings parameters. If that's not possible at least a "0" or "1" for any type change triggering a save. Thanks.

kunkel321
Posts: 664
Joined: 10 Jun 2012 03:45
Location: Near Seattle

Re: Detect whether XY needs saving

Post by kunkel321 »

"Don senses..." LOL. :titter:
TED Notepad puts a "dirty flag" (I guess that's what you call it) by appending an asterisk to whatever is in the window title bar. The * goes away once the text file has been saved. I support that would be less applicable to a file manager, than it is to a text editor though...
ste(phen|ve) kunkel
Scaling: Main monitor 125%, Secondary monitor on the right 100%
OS: Win 10. XYplorer version: Latest beta, unless specified.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Detect whether XY needs saving

Post by TheQwerty »

kunkel321 wrote:TED Notepad puts a "dirty flag" (I guess that's what you call it) by appending an asterisk to whatever is in the window title bar. The * goes away once the text file has been saved. I support that would be less applicable to a file manager, than it is to a text editor though...
Don does something similar to the toolbar button and File | Settings Special menu.

In fact I thought it might be possible for a script to detect this by looking up the captions for those commands but Get('MenuCaption', 193);, etc. don't include the asterisk.

admin
Site Admin
Posts: 66317
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Detect whether XY needs saving

Post by admin »

Note that this asterisk (and the TB Save Settings button green/brown) is not exact science. Not every dirt is registered. Therefore I hesitate to expose this.

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Detect whether XY needs saving

Post by klownboy »

TheQwerty wrote:Don does something similar to the toolbar button and File | Settings Special menu.
Yes, which is essentially what you see when you right click on the save button - an asterick adjacent to the specific setting which has been modified and needs saving. So similar to what you're were thinking, ::button "savesett", 2; will give you the menu and display the asterisk (if any), but I don't think it's possible to detect which one it is or even if it is present.

Don I didn't want to expose any deep dark secrets :wink: , but thought it would be nice from a scripters point of view only to be able to detect whether a save is necessary.

admin
Site Admin
Posts: 66317
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Detect whether XY needs saving

Post by admin »

What I wanted to say: There is no reliable information.

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Detect whether XY needs saving

Post by klownboy »

Thanks Don, though we talked about specific save settings areas like save servers or tags, I would have been happy with using the same flag that you use to turn green to brown on the savesett button to give a general return of "1" or "0" using that same "unreliable" information. :)

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Detect whether XY needs saving

Post by bdeshi »

the save-settings button tooltip/caption also says how many changes are unsaved.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Detect whether XY needs saving

Post by klownboy »

SammaySarkar wrote:the save-settings button tooltip/caption also says how many changes are unsaved.
Wow, yes I forgot about that. Now if we could only capture that I could make some use out of it (i.e., if the save changes number is ≥ "1" » Bingo). RIP BBK - the thrill is gone! :(

Post Reply