ARA (May 2 2009) OK I have a good one. I am working on the Undo function for a program that saves automatically and I am going from a disaster to another. Here is why. Undo does the reverse of the last function which is what it is supposed to do. So far so good. But what happens when the last function is the automatic save? Then it unsaves and it screws up the page, deleting all the contents. Wonderful. Great saving of space. Seriously, what do I do to avoid this situation?

I might decide to take out the Undo button altogether since it is a constant source of headaches. Perhaps the best would be to create a file that would hold all the deleted text and would disappear when I exit. Any suggestions on how to do this?

Finally I'd like to do a back-up of the current page in a directory called back-up that would be attached to the current directory and would make back-ups every 6 minutes on top of the regular automatic saving. I don't want to keep all back-ups simply the latest one. Any suggestions?

I am sure even Microsoft must have bumped into the problem at one point despite the fact that all their text editors save on demand. If you hit Undo after a save in Word, Notepad or in Wordpad, I am sure it won't screw up the page. The key here is to have the program discriminate between a save function and a regular text add-on, edit or delete. If it is a save function, the undo won't work, if if it is a text function (add, edit or delete text) it will work. The problem is: how to make the program discriminate between a text edit and a function such as save? This is the key to the problem. Easier said than done.

The pseudo-code for this will be: if the last moves have been other moves then edit, delete or type in new text, don't do anything; if the last moves have been to edit text, delete text or type in new text, do Undo.

I am learning little by little so please consider that I am not an all-around expert on programming. Thanks a great deal for your help.


Category Help