From: David Reiss on 4 Aug 2010 05:49 Wow that's an early version! :-) On Aug 3, 6:41 am, Themis Matsoukas <tmatsou...(a)me.com> wrote: > Running v.0.0 on a mac, there is no unwanted message. Successive backups are saved without complaint. > > Perhaps the best solution is to switch to a mac :-) > > Themis
From: Murray Eisenberg on 8 Aug 2010 07:21 DirectoryQ works nicely here. I'm surprised it wasn't used in the originally posted code for BareBonesBackup (perhaps the function didn't exist then?). On 8/4/2010 5:47 AM, David Annetts wrote: > Hi Murray, > > There is DirectoryQ ... > > If[Not(a)DirectoryQ[target], CreateDirectory(a)target]; > > D. > > On 2/08/2010 19:03, Murray Eisenberg wrote: >> An exchange reported in between DrMajorBob and Selwyn Hollis >> culminated, in essence, in the code below for creating a saveable >> palette with a button to back up the InputNotebook. >> >> If the target directory for the backup (fixed in the code that creates >> the palette) already exists, then each time I click the button, I get an >> unwanted message >> >> CreateDirectory::filex : ... already exists >> >> in the Messages window. >> >> What is the best way to modify the code so as avoid that message? I can >> think of two methods: >> >> (1) Include a separate test as to whether that directory already exists >> and, if so, by-pass the CreateDirectory phase; or >> >> (2) Somehow trap the CreateDirectory so as to eliminate the message. >> >> For Method (1), how does one tell whether a directory exists? I don't >> find a single function that does it. All I can see is to use first >> FileExistsQ to see if there's some file with the target directory's name >> and second, if the file exists, FileType to check that it's a directory. >> That seems to be getting unduly complicated. >> >> Method (2) in principle seems simpler, and perhaps wrapping Quiet around >> the entire body of the Module (which is an extended If expression) would >> do the trick. But this would also suppress other messages that one might >> want to see, such as when the directory does not already exist but for >> some reason cannot be created; or that the directory exists but for some >> reason is not writable; etc. >> >> Suggestions? >> >> The code: >> >> CreateDocument[PaletteNotebook[Button["Bare Bones Backup", >> Module[{filename,thisnb=InputNotebook[]}, >> If[thisnb=!=$Failed, >> CreateDirectory[ >> ToFileName[{"e:/backups","MmaBareBones"}]]; >> filename= >> StringJoin[ >> StringReplace[(WindowTitle/.AbsoluteOptions[thisnb]), >> s_~~".nb"->s],"_", >> StringJoin[ToString/@ Round/@ Rest[Date[]]],".nb"]; >> Export[ >> ToFileName[{"e:/backups","MmaBareBones"},filename], >> DeleteCases[NotebookGet[thisnb],Cell[_,"Output",___], >> Infinity]]]]], >> Saveable->True]] >> > -- Murray Eisenberg murray(a)math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street fax 413 545-1801 Amherst, MA 01003-9305
From: David Reiss on 9 Aug 2010 05:12 On Aug 8, 7:21 am, Murray Eisenberg <mur...(a)math.umass.edu> wrote: > DirectoryQ works nicely here. I'm surprised it wasn't used in the > originally posted code for BareBonesBackup (perhaps the function didn't > exist then?). > > On 8/4/2010 5:47 AM, David Annetts wrote: > > > > > > > Hi Murray, > > > There is DirectoryQ ... > > > If[Not(a)DirectoryQ[target], CreateDirectory(a)target]; > > > D. > > > On 2/08/2010 19:03, Murray Eisenberg wrote: > >> An exchange reported in between DrMajorBob and Selwyn Hollis > >> culminated, in essence, in the code below for creating a saveable > >> palette with a button to back up the InputNotebook. > > >> If the target directory for the backup (fixed in the code that creates > >> the palette) already exists, then each time I click the button, I get = an > >> unwanted message > > >> CreateDirectory::filex : ... already exists > > >> in the Messages window. > > >> What is the best way to modify the code so as avoid that message? I ca= n > >> think of two methods: > > >> (1) Include a separate test as to whether that directory already exist= s > >> and, if so, by-pass the CreateDirectory phase; or > > >> (2) Somehow trap the CreateDirectory so as to eliminate the message. > > >> For Method (1), how does one tell whether a directory exists? I don't > >> find a single function that does it. All I can see is to use first > >> FileExistsQ to see if there's some file with the target directory's na= me > >> and second, if the file exists, FileType to check that it's a director= y. > >> That seems to be getting unduly complicated. > > >> Method (2) in principle seems simpler, and perhaps wrapping Quiet arou= nd > >> the entire body of the Module (which is an extended If expression) wou= ld > >> do the trick. But this would also suppress other messages that one mig= ht > >> want to see, such as when the directory does not already exist but for > >> some reason cannot be created; or that the directory exists but for so= me > >> reason is not writable; etc. > > >> Suggestions? > > >> The code: > > >> CreateDocument[PaletteNotebook[Button["Bare Bones Backup", > >> Module[{filename,thisnb=InputNotebook[]}, > >> If[thisnb=!=$Failed, > >> CreateDirectory[ > >> ToFileName[{"e:/backups","MmaBareBones"}]]; > >> filename= > >> StringJoin[ > >> StringReplace[(WindowTitle/.AbsoluteOption= s[thisnb]), > >> s_~~".nb"->s],"_", > >> StringJoin[ToString/@ Round/@ Rest[Date[]]],".= nb"]; > >> Export[ > >> ToFileName[{"e:/backups","MmaBareBones"},filen= ame], > >> DeleteCases[NotebookGet[thisnb],Cell[_,"Output= ",___], > >> Infinity]]]]], > >> Saveable->True]] > > -- > Murray Eisenberg mur...(a)math.umas= s.edu > Mathematics & Statistics Dept. > Lederle Graduate Research Tower phone413 549-1020(H) > University of Massachusetts 413 545-2859(W= ) > 710 North Pleasant Street fax 413 545-1801 > Amherst, MA 01003-9305 DirectoryQ is new in version 7
From: telefunkenvf14 on 11 Aug 2010 04:45 On Aug 2, 6:03 am, Murray Eisenberg <mur...(a)math.umass.edu> wrote: > An exchange reported in between DrMajorBob and Selwyn Hollis > culminated, in essence, in the code below for creating a saveable > palette with a button to back up the InputNotebook. This code might interest you: http://sites.google.com/site/qstate/Home Package: Sidebar` (By Yuri E. Kandrashkin) The package Sidebar` includes several interactive tools to control, to navigate, and to trace notebook changes. Main properties of Sidebar` palettes include: - Navigation between the arbitrary selected places in the notebooks - Automatic preserving of the notebook modified cells - Notebook clearing, backuping etc. - Generation of the active table of contents (TOC) - Work with the group of choosen sections/subsections of the notebook (selection, evaluation, hiding, revealing) - Clipboard stack - Symbol information window - Tracing graphics coordinates and the evaluation time - Easy access to special notebooks (ToDo, Memo, Code) - Few more functions, like comparing of two cells of the notebook, locking/unlocking etc -RG > If the target directory for the backup (fixed in the code that creates > the palette) already exists, then each time I click the button, I get an > unwanted message > > CreateDirectory::filex : ... already exists > > in the Messages window. > > What is the best way to modify the code so as avoid that message? I can > think of two methods: > > (1) Include a separate test as to whether that directory already exists > and, if so, by-pass the CreateDirectory phase; or > > (2) Somehow trap the CreateDirectory so as to eliminate the message. > > For Method (1), how does one tell whether a directory exists? I don't > find a single function that does it. All I can see is to use first > FileExistsQ to see if there's some file with the target directory's name > and second, if the file exists, FileType to check that it's a directory. > That seems to be getting unduly complicated. > > Method (2) in principle seems simpler, and perhaps wrapping Quiet around > the entire body of the Module (which is an extended If expression) would > do the trick. But this would also suppress other messages that one might > want to see, such as when the directory does not already exist but for > some reason cannot be created; or that the directory exists but for some > reason is not writable; etc. > > Suggestions? > > The code: > > CreateDocument[PaletteNotebook[Button["Bare Bones Backup", > Module[{filename,thisnb=InputNotebook[]}, > If[thisnb=!=$Failed, > CreateDirectory[ > ToFileName[{"e:/backups","MmaBareBones"}]]; > filename= > StringJoin[ > StringReplace[(WindowTitle/.AbsoluteOptions[thisn= b]), > s_~~".nb"->s],"_", > StringJoin[ToString/@ Round/@ Rest[Date[]]],".nb"]; > Export[ > ToFileName[{"e:/backups","MmaBareBones"},filename], > DeleteCases[NotebookGet[thisnb],Cell[_,"Output",___], > Infinity]]]]], > Saveable->True]] > > -- > Murray Eisenberg mur...(a)math.umas= s.edu > Mathematics & Statistics Dept. > Lederle Graduate Research Tower phone 413 549-1020 (H) > University of Massachusetts 413 545-2859 (= W) > 710 North Pleasant Street fax 413 545-1801 > Amherst, MA 01003-9305
From: Themis Matsoukas on 13 Aug 2010 06:54 Oh well.. I may be a long-time user but not long enough to have seen v0.0. I meant to say 7.0.0. Themis
First
|
Prev
|
Pages: 1 2 Prev: Mathematica- Use a previous equation into the function Function Next: Disable " symbol |