Backing up a stack; problems with save as
Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller
-
jimlehrman
- Posts: 1
- Joined: Wed Jul 10, 2013 7:04 pm
Backing up a stack; problems with save as
I’m wanting to write a script that periodically creates a back up copy of a stack. I want the back up stack to have a unique name that depicts the time it was backed up. But my use of “save as” is not working. I can write scripts that save the stack automatically, but can't get it to save the stack as a separate stack than the original. Can anyone help me with a script that does what I want. Here’s what isn’t working for me:
put "Client Emails BU" && the short date && the time into vBUstack
save this stack as vBUstack
I’ve also tried revSmartSave plugin and it doesn’t seem to do anything. (Maybe it’s too old?)
Thanks for any help on this.
Jimmy
San Diego CA
Paonia CO
put "Client Emails BU" && the short date && the time into vBUstack
save this stack as vBUstack
I’ve also tried revSmartSave plugin and it doesn’t seem to do anything. (Maybe it’s too old?)
Thanks for any help on this.
Jimmy
San Diego CA
Paonia CO
-
scott_morrow
- VIP Livecode Opensource Backer

- Posts: 44
- Joined: Tue Jun 27, 2006 8:35 pm
- Contact:
Re: Backing up a stack; problems with save as
Chipp Walters https://www.altuit.com/ shared a number of great utilities back in the day. I still use this one regularly.
Code: Select all
--|--------------------------------
--| based on the AltArchive plugin
--|
--| Chipp Walters
--| AltArchive version 1.7
--|--------------------------------
on mouseUp
altShowMe
end mouseUp
on altGetInfo
put fld "info" into tMsg
put "altAnswer " & tMsg into toDo
call toDo of stack "AltPlugin"
end altGetInfo
on altGetVersion
send "altAnswer" && first word of fld "info" to stack "AltPlugin"
end altGetVersion
on openStack
if word 1 of the systemVersion is "NT" and word 2 of the systemVersion > 5 then
put queryRegistry("HKEY_CURRENT_USER\Control Panel\Colors\MenuBar") into tColor
if tColor <> "" then
put word 1 of tColor,word 2 of tColor,word 3 of tColor into tColor
set the backgroundColor of this stack to tColor
end if
end if
end openStack
function checkStyle
if the short name of the topStack = the short name of me then
return true
else
return false
end if
end checkStyle
on altShowMe
if the altKey is down then
if the platform is "Win32" then
put the filename of the topstack into tfile
#replace quote with empty in tfile
replace "/" with "\" in tfile
put "attrib"&& quote & tfile & quote && "-R" into DosCommand
put DosCommand
set the hideConsoleWindows to true
put shell (DosCommand)
answer information tfile & cr & "Unlocked"
end if
exit to top
end if
put the short name of the topStack into StackName
put the mainStack of stack StackName into StackName
if the effective filename of stack StackName is empty then
--> THE STACK HAS NEVER BEEN SAVED
answer question "This stack has never been saved." & cr & "Do you wish to save it now?" with "Cancel" or "Okay"
if it is "Cancel" then exit to top
revSaveAs StackName
else
answer question "Archive Stack: " & StackName with "Cancel" and "Okay"
if it is "Cancel" then exit to top
revSave StackName
end if
put the fileName of stack StackName into StackFileName
put the fileName of stack StackName into folderPath
set itemDel to "/"
put the last item of folderPath into fileName
delete last item of folderPath
put folderPath & "/" into folderPath
set itemDel to "."
if the number of items in fileName > 1 then
delete the last item of fileName
end if
set itemDel to ","
put the defaultFolder into savedDF
set the defaultFolder to folderPath
put the files into fileList
--CHECK TO SEE IF ARCHIVE FOLDER EXISTS
if there is not a folder "archive" then
printMsg "making folder Archive",""
create folder "archive"
end if
put folderpath & "archive/" into folderpath
set the defaultFolder to folderPath
repeat with count = 1 to 1000
if count < 10 then
put fileName & "0000" & count & ".rev" into file2save
else
put fileName & "000" & count & ".rev" into file2save
end if
if there is not a file file2save then
-- IF YOU UNCOMMENT THE BELOW YOU NEED TO COMMENT THESE THREE LINES
put "binfile:" & StackFileName into file2copy
printMsg "File to Copy", StackFileName
put "binfile:" & folderpath & file2save into archiveFile
printMsg "Archive File:" ,folderpath & file2save
put url file2copy into url archiveFile
exit repeat
end if
end repeat
set the defaultFolder to savedDF
end altShowMe
on printMsg msg1 msg2
-- --NEED TO COMMENT OUT WHEN IT'S A PALETTE
-- put msg1 & ":" & msg2 into line (the number of lines of fld "test" of stack "revArchive" + 1) of fld "test" of stack "revArchive"
end printMsgElementary Software
...now with 20% less chalk dust!
...now with 20% less chalk dust!
Re: Backing up a stack; problems with save as
I have never tried this. But a simple handler in a button:
does NOT create a new stack such as "backup32". Not sure why not, but will play with it tomorrow when I get to my office with better tools, and to see if the filePath is being improperly ignored.
Craig
Code: Select all
n mouseUp
save this stack as "backup" & random(99)
end mouseUpCraig
Re: Backing up a stack; problems with save as
Not tested, but I suspect a confusion between the "name" of the stack and the "filename" of the stack.
Re: Backing up a stack; problems with save as
Hi Jim,
you need to create a COPY of the binary stackfile on disk!
Something like this (out of my head):
HINT:
This will NOT change the NAME of the stack.
Hope that helps!
Best
Klaus
you need to create a COPY of the binary stackfile on disk!
Something like this (out of my head):
Code: Select all
command saveAcopy
## IMPORTANT to get an up-to-date set of data!:
save this stack
## To make sure the copy is in the SAME directory as the stack
## Change this if you want to save the copy elsewhere
put specialfolderpath("resources") & "/" into tTargetFolder
put tTargetFolder & "Client Emails BU" && the short date && the time into vBUstack
## Filename of the binary file to copy
put the filename of this stack into tSource
put url("binfile:" & tSource) into url("binfile:" & vBUstack)
## Optional, but you'll need to define an EXIT here:
send "saveAcopy" to me in 60 secs
## or whatever frequnency you prefer
end saveAcopyThis will NOT change the NAME of the stack.
Hope that helps!
Best
Klaus
Re: Backing up a stack; problems with save as
So is the dictionary wrong, or am I?
If in a new saved stack I have:
the result is empty, but no such stack exists anywhere on my machine or its cloud. There is a sample in the "save" entry on the dictionary that says this command should create a copy with the supplied name. I assume that since I did not include a filePath, the saved copy would go into the default folder. But at least somewhere.
It seems like a useful command.
And if I:
I get a new stack, but not a renamed copy of the stack I was in.
Craig
If in a new saved stack I have:
Code: Select all
on mouseUp
save this stack as "XYZ-222"
answer the result
end mouseUpIt seems like a useful command.
And if I:
Code: Select all
on mouseUp
create stack "Backup222"
end mouseUp
Craig
Re: Backing up a stack; problems with save as
Hi Craig,
will check the "save" entry in the dictionary.
I would use "clone" to make an identical copy of the current stack:
If you don't supply a full path, then the stack gets saved in the current -> defaultfolder.
On a Mac that may be even inside of the Livecode app package!
I would take a look there!
Best
Klaus
will check the "save" entry in the dictionary.
Yes, and that is correct behaviour, mon ami!I get a new stack, but not a renamed copy of the stack I was in.Code: Select all
on mouseUp create stack "Backup222" end mouseUp
I would use "clone" to make an identical copy of the current stack:
Code: Select all
...
clone this stack as "a brand new stack name here"
## We can clone and rename any object with a one-liner
...Code: Select all
on mouseUp
save this stack as "XYZ-222"
answer the result
end mouseUpOn a Mac that may be even inside of the Livecode app package!
I would take a look there!
Best
Klaus
Re: Backing up a stack; problems with save as
Klaus.
You are saying that a copy of the stack was indeed created, and stored in some distant folder meine Freund?
That I just could not find it? A full search of my computer showed nothing anywhere.
Craig
You are saying that a copy of the stack was indeed created, and stored in some distant folder meine Freund?
That I just could not find it? A full search of my computer showed nothing anywhere.
Craig
Re: Backing up a stack; problems with save as
I'd rather say, it SHOULD!
Try something like this, maybe that will enlighten us:
Try something like this, maybe that will enlighten us:
Code: Select all
on mouseUp
save this stack as "XYZ-222"
answer the FILENAME of this stack
end mouseUp-
richmond62
- Livecode Opensource Backer

- Posts: 10524
- Joined: Fri Feb 19, 2010 10:17 am
Re: Backing up a stack; problems with save as
Why does this not work?
or
viewtopic.php?p=229612&hilit=palette#p229612
Not working either:
Code: Select all
on preOpenStack
palette me
end preOpenStackCode: Select all
on openStack
palette me
end openStackNot working either:
Code: Select all
https://forums.livecode.com/viewtopic.php?p=229612&hilit=palette#p229612Re: Backing up a stack; problems with save as
I have no idea!
Try "on opencard" or create a handler for this and use SEND with a little delay:
Code: Select all
on openstack
send "paletti" to me in 1
end openstackCode: Select all
command paletti
set the style of this stack to "palette"
end paletti