bonnmike at gmail.com
Thu Aug 20 22:38:32 CEST 2015
You'll need to replace the ":" too. This is why apps that do this sort of
thing build up the filename in reverse order, no separators.
Then, no need to mess with all the extraneous chars. (You'll still have to
"sanitize" the name of the stack though)
Perhaps just build things up and urlencode TSTAKN /shrug (or a quoted
string, or 'escape' problematic chars)
On Thu, Aug 20, 2015 at 2:21 PM, Mike Bonner <bonnmike at gmail.com> wrote:
> store the current filename of the stack.
> set the filename of the stack to whatever backup name you want
> save the stack.
> set the filename of the stack back to how it started
> Also, from your example, using " / " as part of the filename would
> probably be a bad idea since / is a directory separator. If you already
> have directories set up, then it would be fine, but since you're using the
> live time and date to do this, its unlikely thats what you were going for.
> Change it to "_" maybe.
> Just a quick and dirty example, but..
> on mouseUp
> set the defaultfolder to specialfolderpath("desktop") --just so I can
> mess around
> palette this stack
> wait 0 with messages -- to make sure the palette is complete before
> moving on
> put the short name of the topStack into TSTAK
> put TSTAK & "_"& the time & "_" & the date into TSTAKN
> replace "/" with empty in TSTAKN -- remove slashes
> replace space with empty in TSTAKN-- the time has a space in it (for AM
> put TSTAKN into fld "TSTAKN"
> -- make sure its been saved before and if so..
> if the filename of the topstack is not empty then
> put the filename of the topstack into tOldFilename -- store the main
> set the filename of the topstack to TSTAKN -- set the temporary
> save stack (the short name of the topstack) -- save the stack
> put the result -- Just so I could see any errors
> set the filename of the topstack to tOldFilename -- revert to the
> main filename
> -- if it wasn't saved already..
> -- set the filename
> set the filename of the topstack to (the short name of the topstack
> & ".livecode")
> -- warn the user that the file will be saved
> answer information "Performing first stack save"
> -- save the file
> save the topstack-- as (the short name of the topstack &
> end if
> end mouseUp
> Obviously, you'll end up with a cleaner script that catches potential
> problems, but it seems to work fine.
> If you really want the slashes and spaces in there, I _THINK_ you might be
> able to pass in a full quoted string.. The spaces are relatively common and
> could be worked around, but I'd be avoiding the slashes.
> On Thu, Aug 20, 2015 at 1:40 PM, Richmond <richmondmathewson at gmail.com>
>> On 19/08/15 23:03, Richard Gaskin wrote:
>>> Richmond wrote:
>>>> Why does this script NOT work in a small stack?
>>>> on mouseUp
>>>> palette stack "AUTOSAVE"
>>>> put the short name of the topStack into TSTAK
>>>> put TSTAK & " / " & the time & " / " & the date into TSTAKN
>>>> put TSTAKN into fld "TSTAKN"
>>>> save the topstack as TSTAKN
>>>> end mouseUp
>>> Does it work on a large stack?
>> By "small stack' I meant that that script is contained in a button on a
>> palettised stack, and is meant to save another stack.
>> It does put the data into the fld "TSTAKN" but does NOT save the top
>> The idea is to convert this code into the cardStack of a palette with a
>> time interval so it serves as a version saver.
>> But any sort of script to save a stack under a different name seems
>> save stack "HEX rotate" as "Granny goes gay"
>> doesn't work either.
>>> It might be problematic with a stack of any size since the date returns
>>> a value that contains "/", which is used as a path delimiter on OS X and
>>> What does "the result" give you after the save command?
>> "can't open stack file"
>>> If instead of changing the path of the current stack what you're looking
>>> to do is make a copy of it to a new location, I'd make a copy of the file
>>> itself and leave the in-memory stack alone.
>>> Richard Gaskin
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
More information about the use-livecode