- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, the application that I'm developing is an engineering application. Users open an existing model database file, do some work, and then save the file. I need a feature to check whether or not the user has actually changed the data in a model so that he/she can be prompted appropriately to save before closing/quiting the application. I have created a rudimentary way of doing this by writing out the structure to file before and after editing and then comparing checksums. This method is not particularly elegant and the checksum routine I obtained is a stand alone executable that I need to run via the SYSTEM command (and thus temporarily throws up a console window over my application). I also have a suspicion that the method is not bomb-proof.
I wonder therefore if anyone has any suggestions or recommendations on how one might implement this?
Thanks,
Angus.
Link Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You could keep track of changes (at least in a rough way) by setting a flag each time the user
presses an OK button or whatever is relevant in your application. Irealise that this is
not always possible or reliable and then saving the data in a file is indeed a much easier
way.
To compare the contents of two files, you could use an MPD5 checksum orSHA1 or any of
these cryptographic keys. You ought to be able to find plenty of implementations on the Internet
for them. It would then be a matter of creating an interface to the routine(s) and then you'd
be independent of an external program
Regards,
Arjen
presses an OK button or whatever is relevant in your application. Irealise that this is
not always possible or reliable and then saving the data in a file is indeed a much easier
way.
To compare the contents of two files, you could use an MPD5 checksum orSHA1 or any of
these cryptographic keys. You ought to be able to find plenty of implementations on the Internet
for them. It would then be a matter of creating an interface to the routine(s) and then you'd
be independent of an external program
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In a GUI application this would often be handled by having every event handling procedure that could modify the data set a document-global file-has-been-changed flag. This same flag is cleared when the document is saved, or if the entire undo stack since the last save gets popped.
(In your case, every "user entry point" style procedure in the "do some work" part of your description would need to set this flag.)
(In your case, every "user entry point" style procedure in the "do some work" part of your description would need to set this flag.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Let's hope that you hold a protected master copy of the data file that user's cannot screw up and replace with the screwed-up version?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks arjenmarkus, the software already knows where a data structure might change so I just need a checking routine. I'll take another look for an implementation of the checksum routines you suggest.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks IanH, yes I already know when the data might change using my own flag model_database_changed. I just need a quick and reliable method for making the check as to whether or not the data in a structure has changed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Good point - hopefully my software will protect the user against this .... but that is yet to be tried in practise! I have not yet coded an undo/redo facility into the software but that is probably something I need to consider for the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
All edit dialogs should operate on a copy of the original data structure. If the user ends the edit with "ok/accept", the edited copy then replaces the original and sets the "changed" flag; if the user cancels the dialog, the edited material simply vaporises and the original is left intact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Paul. It took me some time to recognise that this is what I should be doing but I do now operate in this way.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page