Backing up a stack; problems with save as

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Klaus
Posts: 14364
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Backing up a stack; problems with save as

Post by Klaus »

Yes, that's what I wrote here about six days ago with a script how to do so... 8)
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10550
Joined: Wed May 06, 2009 2:28 pm

Re: Backing up a stack; problems with save as

Post by dunbarx »

Klaus.
Yes, that's what I wrote here about six days ago with a script how to do so... 8)
Calm down, mon ami.

I read your post, and understand that there is a big difference between saving a copy of a stack and saving a copy of a stack file.

The dictionary is correct when it says:

Code: Select all

"save stack [as filePath] [with {format stackFormat | newest format}]
What I was on about was with the dictionary example

Code: Select all

save this stack as "Backup"
If I make a new stack, save it with the name "XXX", then execute that line of code, nothing happens. Neither within LC nor anywhere else on my machine. So forget everything I wrote, and simply tell me what happens, anywhere, when I run that line of code.

Craig
Klaus
Posts: 14364
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Backing up a stack; problems with save as

Post by Klaus »

I'm the calm in person! :-)
What I was on about was with the dictionary example
CODE: SELECT ALL
save this stack as "Backup"
If I make a new stack, save it with the name "XXX", then execute that line of code, nothing happens. Neither within LC nor anywhere else on my machine. So forget everything I wrote, and simply tell me what happens, anywhere, when I run that line of code.
As I also told you calmly before, if you don't supply a path for the stack, on a Mac you may find it in THE DEFAULTFOLDER.
I made a test, created a stack name "test1" and it was the way I had described on the previous page here:

Code: Select all

on mouseUp 
   save this stack as "test2"
end mouseUp
I did not supply a full path, so I ended with the saved stack inside of the APP package*** and without a suffix, see screenshot.
*** Which is the defaultfolder right after LC starts up.
Bildschirmfoto 2026-11-12 um 16.46.12.png
P.S.
save this stack as "new name..."
will ONLY change the filename of the stack, not the (internal) name of the stack and will not add the suffix .livecode
jimlehrman
Posts: 2
Joined: Wed Jul 10, 2013 7:04 pm

Re: Backing up a stack; problems with save as

Post by jimlehrman »

I've been working on this for a quite a while. I've used your suggestions and they've helped to an extent. But the bottom line is that it's not doing what I think the script should make it do. My goal was/is to automate a way to do what the Finder does when I duplicate a file from within the Finder, and either leave the name of the new file as the Finder does (eg: "Client Emails copy 12") or replace the words "copy 12" with a date stamp. (The former is good enough for me. I don't need a date stamp.) I don't want to have to go out of LiveCode and into the Finder to do that, though.

So I created a simple stack which I named "test for cloning". I gave it no stack script. I put one button on the stack and I gave that button this script:

on mouseUp
#### These first 3 lines are just for coming up with a time stamped name for the cloned stack
put the date into vdate
convert vdate to dateItems
put the short name of this stack && item 1 of vdate & "-" & item 2 of vdate & "-" & item 3 of vdate && the short time into vNameBUstack
clone this stack as vNameBUstack
put "Save cloned stack " & vNameBUstack & "?" into vtoSave
answer vtoSave with "cancel" or "yes"
if it is "yes" then save stack vNameBUstack as vNameBUstack
close stack vNameBUstack
end mouseUp

It works just the way I'd like with the MAJOR EXCEPTION THAT IT SAVES THE ORIGINAL STACK, NOT THE CLONED STACK. I put a line in towards the end of the script "put vNameBUstack" to get assurance that I'm telling it to save the cloned stack. But even with that reassurance, it only saves the original stack, as if all those lines of code simply perform the function "save this stack". It successfully clones the original stack, gives it the name I expected, but closes that cloned stack while saving only the original.

What am I doing wrong?

Thank you all for what you've given me that got me this far! Lots of trial and error. And thanks for any additional direction you can share.

Jimmy in San Diego and Colorado
Klaus
Posts: 14364
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Backing up a stack; problems with save as

Post by Klaus »

Jimmy, are you using a Mac?
If yes, take a look at my last posting about "save as..." without supplying a full pathname.
Klaus
Posts: 14364
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Backing up a stack; problems with save as

Post by Klaus »

Your script DEFINITIVELY works, but maybe not how you exspect.
I used a shorter version of your script in a stack named "test1":

Code: Select all

on mouseUp
   lock screen
   put "test2" into vNameBUstack
   clone this stack as vNameBUstack
   ## I ALWAYS provide a full pathname, since the script will fail on a Mac standalone otherwise
   ## We have NO write permissions inside of the App package on other machines than our own!
   save stack vNameBUstack as (specialfolderpath("desktop") & "/" & vNameBUstack & ".livecode")
   close stack vNameBUstack
   unlock screen
end mouseUp
I ended with a COPY of stack "test1" on my desktop and the original stack "test1" was NOT saved during this action.

So I suspect you are on a Mac, please take a look into your App package of "Create" (right-click on the app and select "Show contents...").
I'm sure you will find the missing copies in there.
Post Reply