[OS X TeX] latexdb & texshop

Claus Gerhardt gerhardt at math.uni-heidelberg.de
Thu Oct 13 12:06:36 CEST 2005


Sorry there were two typos in the basic Applescript.

Claus

--Applescript

tell application "TeXShop"
         get path of document of window 1
         set fileName to result
     end tell
     set scriptPath to (do shell script "dirname " & "~/Library/ 
Flashmode/Subroutines/ex")
     set scriptPath to scriptPath & "/setnamets.scpt"
     set scriptName to POSIX file scriptPath as alias
     set scriptLiB to (load script scriptName)
     tell scriptLiB
         set {baseName, texName, pdfName, namePath, dirName,  
dirNameunquoted, logName, logPath, rtfName} to setnamets(fileName)
     end tell



set shellScript to "cd " & dirName & ";"
set shellScript to shellScript & "~/Library/TeXShop/bin/latexdbi  " &  
texName
do shell script shellScript

set shellScript to "cd " & dirName & ";"
set shellScript to shellScript & "~/Library/TeXShop/bin/dvipdfc  " &  
baseName
do shell script shellScript
(*
set pdfName to quotedform of pdfName

set thePDF to POSIX file pdfName as alias
*)
tell document texName of application "TeXShop"
             activate
             refreshpdf
         end tell


%%%%%%%%% end %%%%%%%%%%

On Oct 13, 2005, at 12:02, Claus Gerhardt wrote:

> Ingo,
>
> Try the following script and convince yourself that the required  
> subscripts or subroutines are all available.
>
> Claus
>
> %%%%%%%% begin %%%%%%%
> --Applescript
>
> tell application "TeXShop"
>         get path of document of window 1
>         set fileName to result
>     end tell
>     set scriptPath to (do shell script "dirname " & "~/Library/ 
> Flashmode/Subroutines/ex")
>     set scriptPath to scriptPath & "/setnamets.scpt"
>     set scriptName to POSIX file scriptPath as alias
>     set scriptLiB to (load script scriptName)
>     tell scriptLiB
>         set {baseName, texName, pdfName, namePath, dirName,  
> dirNameunquoted, logName, logPath, rtfName} to setnamets(fileName)
>     end tell
>
>
>
> set shellScript to "cd " & dirName & ";"
> set shellScript to shellScript & "~/Library/TeXShop/bin/latexdbi  "  
> & texname
> do shell script shellScript
>
> set shellScript to "cd " & dirName & ";"
> set shellScript to shellScript & "~/Library/TeXShop/bin/dvipdfc  "  
> & basename
> do shell script shellScript
> (*
> set pdfName to quotedform of pdfName
>
> set thePDF to POSIX file pdfName as alias
> *)
> tell document texName of application "TeXShop"
>             activate
>             refreshpdf
>         end tell
>
>
> %%%%%%%%% end %%%%%%%%%%
>
> -- Save the subroutine setnamets.scpt in ~/Library/TeXShop/Scripts
>
> on setnamets(x)
>     set n to (number of characters of contents of x)
>     set fileNamequoted to quoted form of x
>     set windowName to do shell script "basename " & fileNamequoted
>     set m to (number of characters of contents of windowName)
>     set dirName to quoted form of (characters 1 thru (n - m - 1) of  
> x as string)
>     set dirNameunquoted to (characters 1 thru (n - m - 1) of x as  
> string)
>     set theText to contents of windowName as string
>
>     set n to (number of characters of contents of theText)
>     set i to n as number
>
>     repeat while i > 0
>         if character i of theText is equal to "." then
>             set m to i
>             exit repeat
>         else
>             set i to (i - 1)
>         end if
>     end repeat
>
>     set baseName to (characters 1 thru (m - 1) of theText as string)
>     set texName to baseName & ".tex"
>     set namePath to dirNameunquoted & "/" & baseName as string
>     set pdfName to namePath & ".pdf" as string
>     set rtfName to namePath & ".rtf" as string
>     set logPath to namePath & ".log" as string
>     set logName to baseName & ".log" as string
>
>     try
>         tell application "TeXShop"
>             save document texName
>         end tell
>     end try
>     return {baseName, texName, pdfName, namePath, dirName,  
> dirNameunquoted, logName, logPath, rtfName} as list
> end setnamets
>
>
> On Oct 13, 2005, at 2:30, Claus Gerhardt wrote:
>
>
>> The command in the shell script should be
>>
>>
>>
>>> latexdb  "$1"
>>>
>>>
>>
>>
>> Claus
>>
>>
>> On Oct 13, 2005, at 1:12, Ingo Reich wrote:
>>
>>
>>
>>> Hi,
>>> I'd like to use latexdb from within texshop. (latexdb is a script  
>>> based on python that enables one to connect to mySQL-databases  
>>> from within a latex-file: http://privat.hgesser.com/software/ 
>>> latexdb/). I tried to adapt one of Claus Gerhardts Scripts and  
>>> came up with the one below. The applescript works properly the  
>>> first time it is called, the second time ii is called however  
>>> texshop complains that it can't locate the file example.tex  (in  
>>> German: "Der Ort des Dokuments 'example.tex' konnte nicht  
>>> festgestellt werden"), and it wants me to "save as ...". Any  
>>> ideas what's going wrong here? Thanks,
>>> Ingo
>>>
>>>
>>>
>>> %%%%%%%% begin %%%%%%%
>>> --Applescript
>>>
>>> set scriptPath to (do shell script "dirname " & "~/Library/ 
>>> TeXShop/Scripts/ex")
>>> set scriptPath to scriptPath & "/setname.scpt"
>>> set scriptName to POSIX file scriptPath as alias
>>> set scriptLiB to (load script scriptName)
>>> tell scriptLib
>>> set frontName to setname(#NAMEPATH#,#TEXPATH#)
>>> end tell
>>>
>>> set fileName to  #NAMEPATH#
>>> set n to (number of characters of contents of fileName)
>>> set fileNamequoted to quoted form of fileName
>>> set baseName to do shell script "basename " & fileNamequoted
>>> set m to (number of characters of contents of baseName)
>>> set dirName to quoted form of (characters 1 thru (n - m - 1) of  
>>> fileName as string)
>>> set texName to baseName & ".tex"
>>>
>>> set shellScript to "cd " & dirName & ";"
>>> set shellScript to shellScript & "~/Library/TeXShop/bin/latexdbi   
>>> " & baseName
>>> do shell script shellScript
>>>
>>> tell application "TeXShop"
>>>   activate
>>>   open POSIX file #DVIPATH#
>>> end tell
>>> %%%%%%%%% end %%%%%%%%%%
>>>
>>>
>>> where "latexdbi" is the following binary script:
>>>
>>> %%%%%%%% begin %%%%%%%%%%
>>> #!/bin/tcsh
>>> # latexdbi
>>>
>>> set path= ($path  /usr/local/bin  /usr/local/teTeX/bin/powerpc- 
>>> apple-darwin-current)
>>>
>>> latexdb  "$1.tex"
>>>
>>> %%%%%%%%% end %%%%%%%%%%
>>>
>>> ------------------------- Info --------------------------
>>> Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
>>>          & FAQ: http://latex.yauh.de/faq/
>>> TeX FAQ: http://www.tex.ac.uk/faq
>>> List Archive: http://tug.org/pipermail/macostex-archives/
>>>
>>>
>>>
>>>
>>
>> ------------------------- Info --------------------------
>> Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
>>          & FAQ: http://latex.yauh.de/faq/
>> TeX FAQ: http://www.tex.ac.uk/faq
>> List Archive: http://tug.org/pipermail/macostex-archives/
>>
>>
>>
>
> ------------------------- Info --------------------------
> Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
>          & FAQ: http://latex.yauh.de/faq/
> TeX FAQ: http://www.tex.ac.uk/faq
> List Archive: http://tug.org/pipermail/macostex-archives/
>
>

------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the macostex-archives mailing list