2 ' TortoiseSVN Diff script for Mathematica notebooks
10 ' Szabolcs Horvát, 2008
11 ' Chris Rodgers http://rodgers.org.uk/, 2008
12 ' (Based on diff-xlsx.vbs)
15 dim objArgs
, objScript
, objDiffNotebook
17 Set objArgs
= WScript
.Arguments
20 MsgBox
"Usage: [CScript | WScript] diff-nb.vbs base.nb new.nb", vbExclamation
, "Invalid arguments"
24 sBaseFile
= objArgs(0)
27 Set objScript
= CreateObject("Scripting.FileSystemObject")
29 If objScript
.FileExists(sBaseFile
) = False Then
30 MsgBox
"File " + sBaseFile
+ " does not exist. Cannot compare the notebooks.", vbExclamation
, "File not found"
33 sBaseFile
= objScript
.GetAbsolutePathName(sBaseFile
)
36 If objScript
.FileExists(sNewFile
) = False Then
37 MsgBox
"File " + sNewFile
+ " does not exist. Cannot compare the notebooks.", vbExclamation
, "File not found"
40 sNewFile
= objScript
.GetAbsolutePathName(sNewFile
)
45 Const TemporaryFolder
= 2
47 Set tfolder
= objScript
.GetSpecialFolder(TemporaryFolder
)
49 tname
= objScript
.GetTempName
+ ".nb"
50 Set objDiffNotebook
= tfolder
.CreateTextFile(tname
)
52 'Output a Mathematica notebook that will do the diff for us
53 objDiffNotebook
.WriteLine
"Notebook[{" + vbCrLf
+ _
54 "Cell[BoxData[ButtonBox[""\<\""Compare Notebooks\""\>""," + vbCrLf
+ _
55 "ButtonFrame->""DialogBox"", Active->True, ButtonEvaluator->Automatic," + vbCrLf
+ _
56 "ButtonFunction:>(Needs[""AuthorTools`""];" + vbCrLf
+ _
57 "NotebookPut[Symbol[""NotebookDiff""][" + vbCrLf
+ _
58 """" + Replace(sBaseFile
, "\", "\\") + """," + vbCrLf
+ _
59 """" + Replace(sNewFile
, "\", "\\") + """" + vbCrLf
+ _
60 "]])]], NotebookDefault]" + vbCrLf
+ _
61 "}, Saveable->False, Editable->False, Selectable->False, WindowToolbars->{}, WindowFrame->ModelessDialog, WindowElements->{}, WindowFrameElements->CloseBox, WindowTitle->""Diff"", ShowCellBracket->False, WindowSize->{Fit,Fit}]"
66 Set objShell
= CreateObject("WScript.Shell")
67 objShell
.Run tfolder
+ "\" + tname