Page 1 of 1
"Save As" changes the current file name and location
Posted: Sat Feb 14, 2015 9:52 pm
by sritcp
I save a copy of my stack to a local DropBox folder as a back up every now and again, especially when I am about to try out stuff that can mess up my stack.
If, for example, my file is AddressBook in Documents folder, I "save as" AddressBook02-14-2015 in the DropBox folder.
The problem is that, now the working copy is the back up file. When I "save" hereafter, the back up copy is getting updated. I would like to continue to work on my main copy, not the back up.
Is there any way around it, except to close the current file after backing up, and opening the original file (which I often forget to do, in the heat of the moment!)?
Thanks,
Sri.
Re: "Save As" changes the current file name and location
Posted: Sat Feb 14, 2015 10:40 pm
by jacque
I've found the quickest way is to just flip over to the OS and drag off a copy of the file. Otherwise you'll need a short script. There are some in the User Samples area I think, but the basic idea is just something like this:
Code: Select all
on saveCopy
put "<path/to/dropbox/folder/>" & the short name of this stack && the seconds into tDest
put url ("binfile:" & the filename of this stack) into url ("binfile:" & tDest)
end saveCopy
Pretty easy. I used the seconds since it will keep the files in chronological order without requiring any calculations, but you can use any other unique identifier. If you keep the handler in a backscript somewhere you can just type "saveCopy" into the message box.
Re: "Save As" changes the current file name and location
Posted: Sat Feb 14, 2015 11:49 pm
by bn
Hi Sri,
I tried what you want to do and came up with this. Of course you would have to adjust the path to your dropBox
Code: Select all
on mouseUp
lock screen
clone this stack
put it into tNameOfClone
put tNameOfClone into tWorkingName
replace quote with "" in tWorkingName
replace "Stack Copy of " with "" in tWorkingName
put the seconds into tSeconds
convert tSeconds to dateItems
put item 1 to 3 of tSeconds into tYear
replace comma with "-" in tYear
put item 4 to 6 of tSeconds into tTime
replace comma with "-" in tTime
put specialFolderPath("deskTop") & "/" into tPath
put tWorkingName && tYear && tTime into tNewName
set the name of tNameOfClone to tNewName
put tNewName& ".livecode" after tPath
save stack tNewName as tPath
delete stack tNewName
unlock screen
end mouseUp
gives you a copy of your stack with the original stack name appended by the date and the time in 24 hour format including seconds.
"NameOfYourStack 2015-2-14 23-46-46"
Works nicely, I might even use this myself
Kind regards
Bernd
Re: "Save As" changes the current file name and location
Posted: Sun Feb 15, 2015 8:28 pm
by sritcp
Thanks, Jaque and Bernd !
Jaque, yes, I considered the "put" format, but didn't know how to put the modified contents of a stack directly into a back up file. What you are suggesting, I guess, is to first do a regular "save" to update the stack file on the hard disk, and then make a back up copy of the saved file with the "put" statement.
Bernd, cloning is something I didn't think of. Does cloning copy all sub-stacks, too? (such as Data grid template stack)
The dictionary is not clear about this point.
Regards,
Sri.
Re: "Save As" changes the current file name and location
Posted: Sun Feb 15, 2015 9:04 pm
by bn
Sri,
Does cloning copy all sub-stacks, too? (such as Data grid template stack)
no, not automatically.
I had not thought of that.
Here is a script that I used on a very simple testStack with one substack that had a datagrid. The datagrid was filled with 2 rows of 4 columns each. (manually inserted)
after running my script below the cloned stack opened with the substack and the dataGrid substack attached. The datagrid seemed to work by doing a simple sort. I don't know if the datagrid is depending on the name of the mainstack.
So if you use the script below it is probably a good idea to test it on a copy of your "real" stack and see if everything works.
But for single mainstacks, without substacks it is a fine way to save a working copy of the stack because you can open the backUp stack anytime without name conflicts and have both side by side. Nice for copy paste.
Code: Select all
on mouseUp
lock screen
put the substacks of this stack into tSubStacks -- get the substacks of this mainStack
clone this stack
put it into tNameOfClone
put tNameOfClone into tWorkingName
replace quote with "" in tWorkingName
replace "Stack Copy of " with "" in tWorkingName
put the seconds into tSeconds
convert tSeconds to dateItems
put item 1 to 3 of tSeconds into tYear
replace comma with "-" in tYear
put item 4 to 6 of tSeconds into tTime
replace comma with "-" in tTime
put specialFolderPath("deskTop") & "/" into tPath
put tWorkingName && tYear && tTime into tNewName
set the name of tNameOfClone to tNewName
put tNewName& ".livecode" after tPath
if tSubStacks <> "" then
set the substacks of stack tNewName to tSubStacks -- attach substacks to cloned mainstack
end if
save stack tNewName as tPath
if tSubStacks <> "" then
set the subStacks of this stack to tSubStacks -- reattach substacks to original stack
end if
delete stack tNewName -- removes cloned mainstack from memory
unlock screen
end mouseUp
no guarantees, test before using
Kind regards
Bernd
Re: "Save As" changes the current file name and location
Posted: Sun Feb 15, 2015 10:54 pm
by sritcp
Thanks, Bernd, that should work.
Datagrid template is really a library stack, not a sub-stack.(But my question about sub-stack is still relevant).
Yes, a "working copy" is what I need, especially when I mess around with the innards of data grids, and frequently can't find my way back! It is easier to start over with a fresh copy of the stack than retrace and repair the damage.
Regards,
Sri.
Re: "Save As" changes the current file name and location
Posted: Sun Feb 15, 2015 11:02 pm
by FourthWorld
Doesn't Dropbox automatically maintain versions?
Re: "Save As" changes the current file name and location
Posted: Mon Feb 16, 2015 4:06 pm
by sritcp
FourthWorld wrote:Doesn't Dropbox automatically maintain versions?
It does.
It is a little bit of a bother to retrieve the correct version from DropBox online (not local) backups.
It is good for disaster insurance, but I needed an easier method for my frequent "try out and trash" experiments.
Regards,
Sri
Re: "Save As" changes the current file name and location
Posted: Mon Feb 16, 2015 8:30 pm
by phaworth
Sri,
You might want to take a look at my lcStackBrowser plugin. It's a replacement for the IDE Application/Project browser and has a couple of features that will help you I think.
When you do a "Save As..." in lcStackbrowser, a copy of your stack is saved but you stay in the current stackfile and are not switched to the new one.
Even better for your situation, I think, is lcStackBrowser's Checkpoints feature. At any time, you can create a checkpoint of your stack. It's saved with the date and time and an optional comment. You can keep any number of checkpoints and rollback to any checkpoint at any time.
For example, if you are about to try some major changes to your stack to handle datagrids, as in your example, you would create a checkpoint before starting on the changes. If you get part way through the changes and decide they aren't going to work for you, you can rollback to the checkpoint you created.
The checkpoints are created in a compressed format and are lightening fast to create and rollback to.
A demo version of lcStackBrowser is available at
http://www.lcsql.com/lcstackbrowser.html
Re: "Save As" changes the current file name and location
Posted: Mon Feb 16, 2015 11:02 pm
by sritcp
Peter:
Just what the doctor ordered!
I see that lcStackBrowser is not compatible with the Community Edition, so I must download the Commercial version (I have a Commercial license but haven't bothered to download it, since I am nowhere close to launching a product on Apple or Android store. I use LC locally, for my purposes. So I have so far continued to use the Community version!).
I see you have videos on your website; does it come with a user manual, too?
Regards,
Sri.
Re: "Save As" changes the current file name and location
Posted: Mon Feb 16, 2015 11:36 pm
by phaworth
Hi Sri,
Yes there is a manual. Click the Tools icon and there's an item there to display the menu in whatever pdf viewer you use.
As for community, I am trying to find a way to feel comfortable with removing the passowrd protection, but it's a slow process
Pete
Re: "Save As" changes the current file name and location
Posted: Mon Feb 16, 2015 11:43 pm
by sritcp
Thanks, Peter!
Sri.