Testing whether document has changed
‎Apr 30, 2013
08:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
5 REPLIES 5
‎Apr 30, 2013
08:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
‎Apr 30, 2013
08:19 AM
You can do this with the modified() function.
if (modified(current_doc())) {
# Do something
}
else {
# do something else
}
You can also use this function to set modified to 'false' to disable the prompt before closing
modified(current_doc(), 0);
Chris
if (modified(current_doc())) {
# Do something
}
else {
# do something else
}
You can also use this function to set modified to 'false' to disable the prompt before closing
modified(current_doc(), 0);
Chris
‎Apr 30, 2013
06:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
‎Apr 30, 2013
06:13 PM
Chris,
I believe the if statement needs to have an '=="1" for it to work.
This would only work as the document is being closed though. Once the
document is saved, Epic would not know if the document had been modified or
not (unless change tracking were turned on and you wanted to test for some
value in that).
Jonathan, Epic automatically lets the author know if the file is modified.
In the message bar in the lower right, you'll (or the author) will see a
"MOD" (Epic using the modified function) and Epic will ask if you want to
save the file on closing.
Though with Chris's code, you can force the save.
Lynn
I believe the if statement needs to have an '=="1" for it to work.
This would only work as the document is being closed though. Once the
document is saved, Epic would not know if the document had been modified or
not (unless change tracking were turned on and you wanted to test for some
value in that).
Jonathan, Epic automatically lets the author know if the file is modified.
In the message bar in the lower right, you'll (or the author) will see a
"MOD" (Epic using the modified function) and Epic will ask if you want to
save the file on closing.
Though with Chris's code, you can force the save.
Lynn
‎Apr 30, 2013
09:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
‎Apr 30, 2013
09:28 PM
Lynn,
ACL doesn't have a boolean data type, just strings and integers; thus for locations where other languages would test a boolean, ACL tests whether a value is the number 0, the string "0", or the empty string, ", all of which evaluate as 'false'; everything else is treated as 'true'. So while "if (modified(doc) == 1)" would also work, the "==1" is unnecessary, since modified() returns 0 (false) if the document is not modified.
And, yes, once the document is saved, modified() will return 0. What modified() tests is whether the document contains changes that have not yet been serialized to disk via a save. I took that to be the point of the question. Apologies, if I misunderstood the question.
ACL doesn't have a boolean data type, just strings and integers; thus for locations where other languages would test a boolean, ACL tests whether a value is the number 0, the string "0", or the empty string, ", all of which evaluate as 'false'; everything else is treated as 'true'. So while "if (modified(doc) == 1)" would also work, the "==1" is unnecessary, since modified() returns 0 (false) if the document is not modified.
And, yes, once the document is saved, modified() will return 0. What modified() tests is whether the document contains changes that have not yet been serialized to disk via a save. I took that to be the point of the question. Apologies, if I misunderstood the question.
‎May 01, 2013
05:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
‎May 01, 2013
05:02 AM
The modified function was what I wanted. I have an alias that connects up an ACL function to handle close events, and I wanted to know if the user would be prompted to save, so that I could make sure that some things had been done before saving.
Thanks for you help, Chris and Lynn.
Thanks for you help, Chris and Lynn.
‎May 01, 2013
08:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
‎May 01, 2013
08:21 AM
Chris,
Thanks, being more a document editor with a bit of programming experience, I
wasn't aware of that. I'll give it a try in one of my scripts when I get a
chance.
Lynn
Thanks, being more a document editor with a bit of programming experience, I
wasn't aware of that. I'll give it a try in one of my scripts when I get a
chance.
Lynn