Fix IDs
[TortoiseGit.git] / contrib / diff-scripts / diff-nb.vbs
blob097b494077bf276df8399955b60eb050355168f6
2 ' TortoiseSVN Diff script for Mathematica notebooks
4 ' Last commit by:
5 ' $Author$
6 ' $Date$
7 ' $Rev$
9 ' Authors:
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
18 num = objArgs.Count
19 if num < 2 then
20 MsgBox "Usage: [CScript | WScript] diff-nb.vbs base.nb new.nb", vbExclamation, "Invalid arguments"
21 WScript.Quit 1
22 end if
24 sBaseFile = objArgs(0)
25 sNewFile = objArgs(1)
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"
31 Wscript.Quit 1
32 Else
33 sBaseFile = objScript.GetAbsolutePathName(sBaseFile)
34 End If
36 If objScript.FileExists(sNewFile) = False Then
37 MsgBox "File " + sNewFile + " does not exist. Cannot compare the notebooks.", vbExclamation, "File not found"
38 Wscript.Quit 1
39 Else
40 sNewFile = objScript.GetAbsolutePathName(sNewFile)
41 End If
43 On Error Resume Next
44 Dim tfolder, tname
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}]"
64 objDiffNotebook.Close
66 Set objShell = CreateObject("WScript.Shell")
67 objShell.Run tfolder + "\" + tname