OSDN Git Service

Share resource file between TortoiseGitBlame and TortoiseProc
[tortoisegit/TortoiseGitJp.git] / contrib / other / diff-scripts / diff-nb.vbs
1 '\r
2 ' TortoiseSVN Diff script for Mathematica notebooks\r
3 '\r
4 ' Last commit by:\r
5 ' $Author$\r
6 ' $Date$\r
7 ' $Rev$\r
8 '\r
9 ' Authors:\r
10 ' Szabolcs Horvát, 2008\r
11 ' Chris Rodgers http://rodgers.org.uk/, 2008\r
12 ' (Based on diff-xlsx.vbs)\r
13 '\r
14 \r
15 dim objArgs, objScript, objDiffNotebook\r
16 \r
17 Set objArgs = WScript.Arguments\r
18 num = objArgs.Count\r
19 if num < 2 then\r
20    MsgBox "Usage: [CScript | WScript] compare.vbs base.nb new.nb", vbExclamation, "Invalid arguments"\r
21    WScript.Quit 1\r
22 end if\r
23 \r
24 sBaseDoc = objArgs(0)\r
25 sNewDoc = objArgs(1)\r
26 \r
27 Set objScript = CreateObject("Scripting.FileSystemObject")\r
28 \r
29 If objScript.FileExists(sBaseDoc) = False Then\r
30     MsgBox "File " + sBaseDoc +" does not exist.  Cannot compare the notebooks.", vbExclamation, "File not found"\r
31     Wscript.Quit 1\r
32 Else\r
33     sBaseDoc = objScript.GetAbsolutePathName(sBaseDoc)\r
34 End If\r
35 \r
36 If objScript.FileExists(sNewDoc) = False Then\r
37     MsgBox "File " + sNewDoc +" does not exist.  Cannot compare the notebooks.", vbExclamation, "File not found"\r
38     Wscript.Quit 1\r
39 Else\r
40     sNewDoc = objScript.GetAbsolutePathName(sNewDoc)\r
41 End If\r
42 \r
43 On Error Resume Next\r
44 Dim tfolder, tname, tfile\r
45 Const TemporaryFolder = 2\r
46 \r
47 Set tfolder = objScript.GetSpecialFolder(TemporaryFolder)\r
48 \r
49 tname = objScript.GetTempName + ".nb"\r
50 Set objDiffNotebook = tfolder.CreateTextFile(tname)\r
51 \r
52 'Output a Mathematica notebook that will do the diff for us\r
53 objDiffNotebook.WriteLine "Notebook[{" + vbCrLf + _\r
54 "Cell[BoxData[ButtonBox[""\<\""Compare Notebooks\""\>""," + vbCrLf + _\r
55 "ButtonFrame->""DialogBox"", Active->True, ButtonEvaluator->Automatic," + vbCrLf + _\r
56 "ButtonFunction:>(Needs[""AuthorTools`""];" + vbCrLf + _\r
57 "NotebookPut[Symbol[""NotebookDiff""][" + vbCrLf + _\r
58 """" + Replace(sBaseDoc,"\","\\") + """," + vbCrLf + _\r
59 """" + Replace(sNewDoc,"\","\\") + """" + vbCrLf + _\r
60 "]])]], NotebookDefault]" + vbCrLf + _\r
61 "}, Saveable->False, Editable->False, WindowToolbars->{}, WindowFrame->ModelessDialog, WindowElements->{}, WindowFrameElements->CloseBox, WindowTitle->""Diff"", ShowCellBracket->False, WindowSize->{Fit,Fit}]"\r
62 \r
63 \r
64 objDiffNotebook.Close\r
65 \r
66 Set objShell = CreateObject("WScript.Shell")\r
67 objShell.Run tfolder + "\" + tname\r