How to know if an object has been edited/modified?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How to know if an object has been edited/modified?
Is it possible to set a flag (set the cEdited of object "X" to false) and have it update when the object is modified in some way (the text, or backgroundColor, or anything at all) ?
My example below uses a DataGrid, but my question is general to any object.
I have a DataGrid on each card. When a card is closed, it use the data of the DataGrid to update a master data table. Many times, the user may go to a card to view information and not alter the data. It would be wasteful and inefficient to write the data out when nothing was modified. It would be helpful if, on openCard, we could set the cEdited of the DataGrid to false, and, on closeCard, the program could look at the custom property to see if the object has been modified, and update only when necessary.
Thanks,
Sri.
My example below uses a DataGrid, but my question is general to any object.
I have a DataGrid on each card. When a card is closed, it use the data of the DataGrid to update a master data table. Many times, the user may go to a card to view information and not alter the data. It would be wasteful and inefficient to write the data out when nothing was modified. It would be helpful if, on openCard, we could set the cEdited of the DataGrid to false, and, on closeCard, the program could look at the custom property to see if the object has been modified, and update only when necessary.
Thanks,
Sri.
Re: How to know if an object has been edited/modified?
Check out this thread:
http://forums.livecode.com/viewtopic.ph ... sal#p20678
It should be touted more loudly. It ought to do what you need, if you write a handler high up in your stack hierarchy.
Craig newman
http://forums.livecode.com/viewtopic.ph ... sal#p20678
It should be touted more loudly. It ought to do what you need, if you write a handler high up in your stack hierarchy.
Craig newman
Re: How to know if an object has been edited/modified?
Hi Craig:
I went over the thread and I must admit that it was somewhat above my pay grade!
I understand frontscript and the concept of pre-handling a message, but it is not clear to me how to code the "modification" of an object. For instance, the user may click to open a DataGrid cell (or even a simple text field), and leave without entering/modifying the text. In such a case, openField and closeField messages would be sent to the field (not sure what messages in the case of DataGrid), but it doesn't say anything about whether the object was modified (in this case, if the text was edited).
Regards,
Sri.
I went over the thread and I must admit that it was somewhat above my pay grade!
I understand frontscript and the concept of pre-handling a message, but it is not clear to me how to code the "modification" of an object. For instance, the user may click to open a DataGrid cell (or even a simple text field), and leave without entering/modifying the text. In such a case, openField and closeField messages would be sent to the field (not sure what messages in the case of DataGrid), but it doesn't say anything about whether the object was modified (in this case, if the text was edited).
Regards,
Sri.
Re: How to know if an object has been edited/modified?
Hi Sri,
Why not something like that pseudocode ?:
• at opencard
Build the list of the relevant properties for each object of the card
• at closecard
Compare this list with a new list of the relevant properties for each object of the card
Best regards
Jean-Marc
Why not something like that pseudocode ?:
• at opencard
Build the list of the relevant properties for each object of the card
• at closecard
Compare this list with a new list of the relevant properties for each object of the card
Best regards
Jean-Marc
https://alternatic.ch
Re: How to know if an object has been edited/modified?
You could modify the scripts of each object in question to include a line that changes the value of a custom property. So, on openCard you set the cNeedsToBeSaved of this stack to false. Now each modifiable field could have on keyDown set the cNeedsToBeSaved of this stack to true. Since I assume that the end user will be using a standalone and not the stack, any backgrounds and colors and sizes would have to be changed by script, so include that same custom property change in those scripts. Now on closeCard if the cNeedsToBeSaved of this stack is true then doYourThing.
Re: How to know if an object has been edited/modified?
hi,
That thread dealt with a generalized message, er message. In other words, script changes.
Are you familiar with the "properties" property? You can store the whole list in a custom property, and check it en masse at any subsequent time. In this way, you do not need to delineate any particular property or properties, you simply run the entire list and pull out those lines that have changed.
If you are interested only in certain properties, then do as Bernd or Magice suggested, and form a custom list. The idea is the same, but the complete list is more robust in that you never need to worry about adding or subtracting properties, since only the ones that have changed need be reported.
Note that the script of an object is a property of that object. This, too would appear in that list of changes.
Craig
That thread dealt with a generalized message, er message. In other words, script changes.
Are you familiar with the "properties" property? You can store the whole list in a custom property, and check it en masse at any subsequent time. In this way, you do not need to delineate any particular property or properties, you simply run the entire list and pull out those lines that have changed.
If you are interested only in certain properties, then do as Bernd or Magice suggested, and form a custom list. The idea is the same, but the complete list is more robust in that you never need to worry about adding or subtracting properties, since only the ones that have changed need be reported.
Note that the script of an object is a property of that object. This, too would appear in that list of changes.
Craig
Re: How to know if an object has been edited/modified?
I agree and understand that by long-handed scripting we can check if each property of each object has changed.
I was wondering if there was a short-cut, in the form of an existing message or command.
I think it would be great if a generic "objectModified" message is sent to an object when any of its property is modified.
I am sure there is a ton of ways in which it could be put to use.
May be someone could put in a suggestion to RunRev.
Thanks,
Sri.
I was wondering if there was a short-cut, in the form of an existing message or command.
I think it would be great if a generic "objectModified" message is sent to an object when any of its property is modified.
I am sure there is a ton of ways in which it could be put to use.
May be someone could put in a suggestion to RunRev.
Thanks,
Sri.
Re: How to know if an object has been edited/modified?
It is a good idea, sort of along the lines of the "setProp"/"getProp" control structures. But these only work with custom properties, not mainstream ones.
Put it into the features request pane.
Craig
Put it into the features request pane.
Craig
Re: How to know if an object has been edited/modified?
I did.dunbarx wrote: Put it into the features request pane.
This is also relevant to autosaving a stack. I'd like to set it to save every 5 minutes (or 30 minutes), but only if the stack has been modified. I don't want an unmodified stack saved 12 times when I went away from the computer for an hour!
How do you handle this currently?
Regards,
Sri.
Re: How to know if an object has been edited/modified?
This goes right back to the original issue. Though in this case, you do not care what property has been modified, only that at least one has been. So create a routine somewhere that sends a message every five minutes. Test the "properties" property of your stack against the previous state of that property, stored in a custom property. If it is different, save the stack.
Craig
Craig
Re: How to know if an object has been edited/modified?
It is more involved than that. If any property of any object has changed, we'd need to save the stack. This would mean comparing before and after of each property of each object in the stack every 5 minutes - which is not practical.dunbarx wrote: Test the "properties" property of your stack against the previous state of that property, stored in a custom property. Craig
If LiveCode were to send an "objectModified" message to an object every time a property is changed, we could trap the message at the stack level (in the message path) and flag that the stack needs to be saved.
I am sure such a message can be used in all sorts of ways to increase efficiency.
Thanks,
Sri.
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: How to know if an object has been edited/modified?
Do you really want to save the stack, or the data the user had edited?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How to know if an object has been edited/modified?
Save the stack.
Take an example. While developing a program, I am the "user", and I'd like to autosave my work, say, every 5 minutes. (I've had LiveCode crash a few times, losing unsaved work).
Much of the time the program is open, even when I am not working on it.
I don't want it to save it every 5 min if I have done nothing to the stack.
I want it to save only when the content of the stack has changed.
Thanks,
Sri.
Take an example. While developing a program, I am the "user", and I'd like to autosave my work, say, every 5 minutes. (I've had LiveCode crash a few times, losing unsaved work).
Much of the time the program is open, even when I am not working on it.
I don't want it to save it every 5 min if I have done nothing to the stack.
I want it to save only when the content of the stack has changed.
Thanks,
Sri.
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: How to know if an object has been edited/modified?
If you haven't done anything in several minutes or might be time to take a break. 
There's an auto-same plugin available, possibly even included in the install.
Just how long does it take to save your stack file?

There's an auto-same plugin available, possibly even included in the install.
Just how long does it take to save your stack file?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How to know if an object has been edited/modified?
"I know hard work never killed anyone, but why take a chance?" Ronald ReaganFourthWorld wrote:If you haven't done anything in several minutes or might be time to take a break.
Misses the point. May be my example wasn't a great one.Just how long does it take to save your stack file?
I couldn't believe there wasn't a simple, non-convoluted way to determine when an object has been modified.
It appears there isn't.
Regards,
Sri.