Save an object's properties to a text file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Save an object's properties to a text file
Hello.
I'm working on a project in Revolution and need to generate a number of "image" objects based on a common template image object. I've set up an image object just how I want the template image object to be, and am curious if I can save the settings of the object to a text file and later reload them to create more image objects.
An alternative method would be to set up my image object and then make it invisible, and copy it, but I'd prefer to generate the objects completely dynamically from settings stored in a file. I'm not able to find any good documentation on the entire list of properties available to Revolution objects, so I'd just like to save the existing properties to a file, and reload them later. Any ideas?
I'm working on a project in Revolution and need to generate a number of "image" objects based on a common template image object. I've set up an image object just how I want the template image object to be, and am curious if I can save the settings of the object to a text file and later reload them to create more image objects.
An alternative method would be to set up my image object and then make it invisible, and copy it, but I'd prefer to generate the objects completely dynamically from settings stored in a file. I'm not able to find any good documentation on the entire list of properties available to Revolution objects, so I'd just like to save the existing properties to a file, and reload them later. Any ideas?
Dear mokogobo,
I export all properties of all objects and cards of a stack to an XML file, for DIFfersifier (which is at http://economy-x-talk.com/differsifier.html ). It is quite simple to do this, using the propertynames function and a repeat loop.
I wouldn't do this, however, only to replicate an object inside Revolution. If this is all you want, it is so much easier to save a custom template object in your project and copy it to wherever you need it. A simple copy command is much easier and probably much faster than reading all properties from a file and setting the properties of an object using a repeat loop.
Best,
Mark
I export all properties of all objects and cards of a stack to an XML file, for DIFfersifier (which is at http://economy-x-talk.com/differsifier.html ). It is quite simple to do this, using the propertynames function and a repeat loop.
I wouldn't do this, however, only to replicate an object inside Revolution. If this is all you want, it is so much easier to save a custom template object in your project and copy it to wherever you need it. A simple copy command is much easier and probably much faster than reading all properties from a file and setting the properties of an object using a repeat loop.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Do you mean to create the object, make it invisible or store it to a "template card" and just copy it, or is there a better way?Mark wrote:If this is all you want, it is so much easier to save a custom template object in your project and copy it to wherever you need it. A simple copy command is much easier and probably much faster than reading all properties from a file and setting the properties of an object using a repeat loop.
Okay. That's what I originally did, but it felt a bit too "hacky". I found that the "templateImage" can be configured to set the default properties for new images created. This seems like a nice way to go about it...Mark wrote:Dear mokogobo,
Yes, that's what I mean.
Best,
Mark
I'm thinking:
1) Initially load properties from an XML file and close file
2) Use the loaded properties to set the templateImage
3) Create any images needed
4) Reset the template image
Anyway, thanks for your direction.
Hi mokogobo,
You should just save the object in your project and copy it when you need it. That's the best way to do it.
Best regards,
Mark
You should just save the object in your project and copy it when you need it. That's the best way to do it.
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Alright. Is the best way to save it to a new card on the same stack, or a new stack? I'm having some trouble copying the image from another card on the same stack... it closes the current card or makes it invisible. While I could switch back to the desired card, I'd prefer the copying took place in the background. Any pointers?Mark wrote:Hi mokogobo,
You should just save the object in your project and copy it when you need it. That's the best way to do it.
Best regards,
Mark
Dear mokogobo,
It doesn't matter where you keep the object, as long as it is part of your project. You need to refer to the object as part of a stack, if it isn't part of the current stack: copy img x of cd y of stack z to this cd.
The stack with the object needs to be in memory. I am not sure, right now, whether the card with the object has to be on screen. If is has to be, you can still set the right of the stack to -100, to make it invisible, or perhaps set the invisible of the stack to true. Just experiment a but and see what works best for you.
Best regards,
Mark
It doesn't matter where you keep the object, as long as it is part of your project. You need to refer to the object as part of a stack, if it isn't part of the current stack: copy img x of cd y of stack z to this cd.
The stack with the object needs to be in memory. I am not sure, right now, whether the card with the object has to be on screen. If is has to be, you can still set the right of the stack to -100, to make it invisible, or perhaps set the invisible of the stack to true. Just experiment a but and see what works best for you.
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode