Forum Moderators: open

Message Too Old, No Replies

Would you like to save changes?

Uh..nothing has changed..or has it?

         

vik_c

10:30 am on Oct 13, 2008 (gmt 0)

10+ Year Member



When I open a text file, delete a word, add it back again, it's exactly as it was earlier, in the same position. Similarly if I paste something and undo it, nothing's changed. Yet, in these scenarios I'm asked by Windows if I want to 'save changes'. What changes are these? Nothing's changed, has it? Why the prompt?

janharders

10:44 am on Oct 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



that depends on the editor you're using. ultraedit for example will ask me to save changes if I delete a word and then type it again, however, it will recognize that no changes have happened if I use the undo-function. I guess that it's just programmers not wanting to have to check the state of the editor and the contents of the file all the time - if you delete a word and then manually retype it, those are all "actions" for the editor -- if you use the undo-function, you're undoing those actions and once you're back to zero actions, it's easy to decide that there are no changes.

if you're using word or similar programs, they seem to think something changed if you just looked at one document for more than 7 seconds ;)

Shaddows

10:44 am on Oct 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I would guess, though I am not a progammer, that the 'save changes' prompt is a one-way activation. It gets activated once a change is made, and does not represent a comparison of 'sameness' by the program in question.

httpwebwitch

12:56 pm on Oct 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sometimes you want to reasve a file with no changes in order to bump up it's modified date. there's a unix command for that: "touch"

I remember always having to "touch" the web.config file in IIS in order for new settings to take effect, otherwise the server uses some kind of cache which was annoying. Open in notepad, add a space, remove a space, resave.

So even though the contents of the file have not changed, the file has changed because you molested it. When it concerns cached media on the web, those timestamps really matter.

vik_c

5:43 pm on Oct 13, 2008 (gmt 0)

10+ Year Member



Interesting. Clearly there's some method to the madness :)

rocknbil

8:33 pm on Oct 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



From a Windows programming standpoint . . .

In the early stages of learning Basic and Visual basic, one of the projects is a text editor. There is usually a "Dirty" flag, a boolean true false value, set when the first document opens.

When you make a change to it, the dirty flag is set to true. When you save the document, the dirty flag is reset to false.

When you close the document, if the dirty flag is true, you are prompted to save before closing because the document is only in memory, it has not been written to a file.

These are handled by predefined functions in most libraries accessible to programmers, similar to the onChange function in Javascript. It's the same concept - you can't tell what's changed, only that it has changed.

When you paste the same word back in, human interpretation knows the file is unchanged, but because of this efficient (in terms of programming) way of managing document changes, the program does not. Using an onChange handler doesn't read the entire document . . . . get it? :-)

This can be done but it requires . . . more resources and complications for the programmer, which may or may not add up to slower running and memory problems. You open the document and you have to maintain a "copy" in memory or on hard disk, and have to compare it against the copy before closing. A lot of work for such a little thing . . . this is also why sometimes when a program crashes you will see files in your working directory: ms~01234566word.tmp (or something like it.) These are normally cleaned up when the program exits.

I have a few programs (HomeSite is one) that correctly reset when you undo or paste the words back in. But most programs don't, it's just as easy to let the user worry about it.

vik_c

2:47 pm on Oct 15, 2008 (gmt 0)

10+ Year Member



I get your point rocknbil, very clearly explained. Thanks.

rocknbil

11:29 pm on Oct 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Was tired, sorry. :-P