MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Bare Bones Backup Button


Bobby,

Thanks again for the Windows repairs. On the saveability issue, wrap  
SetOptions around it with the option Saveable->True.

-Selwyn


On Jun 12, 2007, at 4:58 AM, DrMajorBob wrote:

> That doesn't work in Windows ($HomeDirectory is read-only, among  
> other things), but this does:
>
> CreatePalette[{Button["Bare Bones Backup",
>     Module[{filename, thisnb = InputNotebook[]},
>      If[thisnb =!= $Failed,
>       CreateDirectory[
>        ToFileName[{$UserBaseDirectory, "MathBackups"}]];
>       filename =
>        StringJoin[
>         StringReplace[(WindowTitle /. AbsoluteOptions[thisnb]),
>          s_ ~~ ".nb" -> s], "_",
>         StringJoin[ToString /@ Round /@ Rest[Date[]]], ".nb"];
>       Export[
>        ToFileName[{$UserBaseDirectory, "MathBackups"}, filename],
>        DeleteCases[NotebookGet[thisnb], Cell[_, "Output", ___],
>         Infinity]]]]]}];
>
> Execute the code, and it creates the palette. Now... and this is  
> dumb... grab the palette and move it. Then close it, and  
> Mathematica asks if you want to save the palette.
>
> If you DON'T move it, there's no way (I can find) to save the  
> palette. Using Selwyn's CreateDocument version, even moving the  
> palette doesn't work.
>
> I discovered the needed changes by trial and error; the  
> documentation was no help at all. There are dozens of palette and  
> notebook creation examples, but none of them (that I could find)  
> show how to save the result.
>
> Bobby
>
> On Tue, 12 Jun 2007 00:23:53 -0500, Selwyn Hollis  
> <sh2.7183 at earthlink.net> wrote:
>
>> This is something I've wanted for years. Click the button, and a copy
>> of the current InputNotebook -- with output cells deleted -- is
>> Exported into a backup folder in your $HomeDirectory.
>>
>> CreateDocument[PaletteNotebook[
>> Button["Bare Bones Backup",
>>     Module[{filename, thisnb = InputNotebook[]},
>>      If[thisnb =!= $Failed,
>>       CreateDirectory[ToFileName[{$HomeDirectory, "MathBackups"}]];
>>       filename =  StringJoin[
>>         StringReplace[(WindowTitle /. AbsoluteOptions[thisnb]),
>>          s_ ~~ ".nb" -> s], "_",
>>           StringJoin[ToString /@ Round /@ Rest[Date[]]], ".nb"];
>>       Export[ToFileName[{$HomeDirectory, "MathBackups"}, filename],
>>        DeleteCases[NotebookGet[thisnb], Cell[_, "Output", ___],
>> Infinity]]
>>       ] ] ] ] ]
>>
>> (Button is new to 6, but the function inside Button should work fine
>> in 5.2.)
>>
>> I've got a version of this that runs automatically every 15 minutes
>> (you can change the interval, of course). Anyone who's interested
>> should let me know.
>>
>> Selwyn Hollis
>>
>>
>
>
>
> -- 
> DrMajorBob at bigfoot.com



  • Prev by Date: Re: Trouble with a system of equations
  • Next by Date: OpenSSH mathlink remote kernel connection problem.
  • Previous by thread: Re: Bare Bones Backup Button
  • Next by thread: Re: Bare Bones Backup Button