saving stacks to db
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
saving stacks to db
Does anyone know of a way to save a stack in memory to a database without saving to drive first? Or ftp the stack live without saving first? Or even stuffing a stack into a property?
Re: saving stacks to db
Figured out a method that seems to work well enough.
If anyone is interested heres a description of the method
copy the stack to the clipboard
copy stack "stackname"
At this point simply stuff the clipboarddata wherever you want it saved. A property, or database, or send it to a web server for handling or whatever.
To get it back, retrieve the data, stuff it back into the clipboarddata and "paste"
set the clipboarddata["objects"] to <what ever ccontains the saved data>
paste
Voila', up pops the stack. Interestingly enough, since paste is smart, it checks to see if the stack already exists and if it does, changes it to "copy of stack..." as if you hadn't gone through all the steps. If the stack isn't in memory already, the name remains as it was.
If anyone is interested heres a description of the method
copy the stack to the clipboard
copy stack "stackname"
At this point simply stuff the clipboarddata wherever you want it saved. A property, or database, or send it to a web server for handling or whatever.
To get it back, retrieve the data, stuff it back into the clipboarddata and "paste"
set the clipboarddata["objects"] to <what ever ccontains the saved data>
paste
Voila', up pops the stack. Interestingly enough, since paste is smart, it checks to see if the stack already exists and if it does, changes it to "copy of stack..." as if you hadn't gone through all the steps. If the stack isn't in memory already, the name remains as it was.
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: saving stacks to db
Good work, Sturgis. It would never have occurred to me that the copy command will work on a stack. Very handy....
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: saving stacks to db
Cool, didn't know this, thanks for the info!
Re: saving stacks to db
Opens up some interesting possibilities. LIke a versioning system, or what I am trying to work up, a plugin so that a class working on write locked systems (public lab, systems are overwritten every night with a fresh clean image) so that stacks can be saved to a central db tagged by user. Accessible from any station etc.
No builds without a real save of course so something will have to be figured out for that.
No builds without a real save of course so something will have to be figured out for that.
Re: saving stacks to db
If anyone is interested, this works great for stacks with no substacks.
To copy a stack and all its substacks to an array, loop through the substacks and shove them into the array first, set their mainstack to themselves, when the substacks are done, the mainstack is now a single stack. Save it to the array tagged as main some way. THen loop through the subs again and set their mainstack back to normal.
Seems pretty fast, works well. I have a test stack so far that will backup any named stack and its substacks to an array that is stuffed into a property. Database backup with date stamps next hopefully.
To copy a stack and all its substacks to an array, loop through the substacks and shove them into the array first, set their mainstack to themselves, when the substacks are done, the mainstack is now a single stack. Save it to the array tagged as main some way. THen loop through the subs again and set their mainstack back to normal.
Seems pretty fast, works well. I have a test stack so far that will backup any named stack and its substacks to an array that is stuffed into a property. Database backup with date stamps next hopefully.