Ive been working on this from morning to midnight (primarily studying the docs that never seem to have useful examples) only to to make very little ground. I am trying to code a dynamic button that performs a recurring NotebookSave[]
after a countdown timer[s]
completes and then automatically begins cycle again.
The button should do the following...
when inactive label should display
AutoSave
.click replaces label with time remaining for next save.
when countdown
timer[s]
completes this should triggerNotebookSave[]
.label should now read
SAVED
for10 sec
(I thinkPause[10]
would work).automatically start cycle over perhaps by recursive function (only closing notebook will stop autosave).
and finally the entire thing nicely packaged in a
DynamicModule[]
which I should find doing a piece of cake.
From the code below you can see I only completed steps 1 and 2 (step 3 attempted but failed). Any help for steps 3 - 5 would be most appreciated. I also include a small sampling of my many bad attempts so you would take pity on my wretched soul.
timer[s_ : 600] := Dynamic[s - Clock[{0, s, 1}, s, 1]];
s = 10;
Button[Dynamic[x, {(x := #) &, NotebookSave[]},
Initialization :> (x := "AutoSave")], x := timer[s]]
(* may ignore these bad attempts *)
(*
Button[Dynamic[x,{}Initialization:>(x:="AutoSave")],(x:=timer[];\
NotebookSave)];
Button[Dynamic[x,Initialization:>(x:="AutoSave")],Dynamic[x,{x:=timer[\
],NotebookSave[]}]];
Button[Dynamic[x,Initialization:>(x:="AutoSave")],x:=Dynamic[t,{t:=\
timer[s],If[t==0,NotebookSave[]]}]]
Button[Dynamic[x,Initialization:>(x:="AutoSave")],x:=Dynamic[t,{t:=\
timer[s],If[t==0,NotebookSave[]]}]]
*)