summaryrefslogtreecommitdiff
path: root/Master/texmf
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf')
-rw-r--r--Master/texmf/scripts/bitmap2eps/bitmap2eps.vbs103
1 files changed, 103 insertions, 0 deletions
diff --git a/Master/texmf/scripts/bitmap2eps/bitmap2eps.vbs b/Master/texmf/scripts/bitmap2eps/bitmap2eps.vbs
new file mode 100644
index 00000000000..331b379badb
--- /dev/null
+++ b/Master/texmf/scripts/bitmap2eps/bitmap2eps.vbs
@@ -0,0 +1,103 @@
+option explicit
+On Error Resume next
+
+dim oWsh, oArgs, oFS, oTS, infile, outfile, f, c, result
+
+', oFS, oEnv, tlroot, script_path, Return, cmd
+set oWsh = createobject( "wscript.Shell" )
+Set oFS = CreateObject("Scripting.FileSystemObject")
+'Set oEnv = oWsh.Environment("PROCESS")
+Set oArgs = wscript.arguments
+'tlroot = (oFS.GetParentFolderName(oFs.GetParentFolderName( _
+' oFS.GetParentFolderName(WScript.ScriptFullName))))
+'If Right(tlroot,1) <> "\" Then
+' tlroot = tlroot & "\"
+'End If
+
+' assume sam2p and bmeps on searchpath
+If oArgs.count = 0 Then
+ messageBox "Nothing to do"
+ wscript.quit
+End If
+
+' name of output file
+
+' may have to flip slashes if the file was on a network drive !!!
+infile = replace(oArgs(0), "/", "\")
+infile = ofs.getabsolutepathname(infile)
+outfile = ofs.buildpath(ofs.getparentfoldername(infile), _
+ ofs.getbasename(infile) & ".eps")
+
+If ofs.fileexists(outfile) Then
+ result = MsgBox(outfile & vbcrlf & "exists; overwrite?", _
+ vbyesno+vbquestion)
+ If result <> vbyes Then
+ wscript.quit
+ Else
+ oFS.deletefile(outfile)
+ Err.clear
+ If ofs.fileexists(outfile) Then
+ MsgBox "Unable to memove old " & outfile, vbcritical
+ wscript.quit
+ End If
+ End If
+End If
+
+' MsgBox "trying sam2p"
+owsh.run "sam2p """ & infile & """ EPS: """ & outfile & """", 0
+If Err Then
+ MsgBox "Unspecified failure", vbcritical
+ wscript.quit
+End If
+wscript.sleep(1000)
+
+If ofs.fileexists(outfile) Then
+ MsgBox ofs.getbasename(infile) & "." & ofs.getextensionname(infile) & _
+ " successfully converted", vbInformation
+Else
+ Err.clear
+ ' clear sam2p temp files
+ For Each f in ofs.getfolder(ofs.getparentfoldername(infile)).files
+ If InStr(f.Name, "tmp__sam2p") = 1 Then
+ f.delete
+ Err.clear
+ End If
+ Next
+ ' MsgBox "trying bmeps"
+ owsh.run "bmeps -c """ & infile & """ """ & outfile & """", 0
+ If Err Then
+ MsgBox "Unspecified failure", vbcritical
+ wscript.quit
+ End If
+ wscript.sleep(1000)
+ If ofs.fileexists(outfile) Then
+ result = True
+ ' check the eps file.
+ ' bmeps may have written an error message to it.
+ Set oTS = ofs.opentextfile (outfile, 1)
+ If Err Then
+ result = False
+ Err.clear
+ Else
+ c = oTS.read(2)
+ If Err Then
+ result = false
+ Err.clear
+ Else
+ If c <> "%!" Then
+ result = False
+ End If
+ End If
+ oTS.close
+ End If
+ If result then
+ MsgBox ofs.getbasename(infile) & "." & ofs.getextensionname(infile) & _
+ " successfully converted with bmeps", vbInformation
+ Else
+ 'ofs.deletefile(outfile)
+ MsgBox "Conversion failed", vbCritical
+ End If
+ Else
+ MsgBox "Conversion failed", vbCritical
+ End If
+End If