home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fonts 1 / freshfonts1.bin / programs / amiga / pastex / rexx / start_tex.sd < prev    next >
Text File  |  1991-07-29  |  3KB  |  125 lines

  1. /*RX
  2.  * AREXX    Name:Start_TeX.sd    Version:1.41    Date:27-Jul-91
  3.  *
  4.  This AREXX script saves and compiles the current view using the last
  5. format used, unless you supply a format name as argument. A '?'
  6. formatname will interactively ask for the format to use. If no format
  7. is supplied and the TeX-server has been set up to always ask for the
  8. default format, then it will do so here. Even under WB 1.3
  9.  *
  10.  A command is send to the TeX server to compile the file. Hence a
  11. return value of 0 does not mean that the file compiled well, but only
  12. that the command was sent to the server and replied to.
  13.  *
  14. AUTHOR:
  15.  *    J\"org H\"ohle, March 91
  16.  *    Revised: 24 July 1991
  17. BUGS:
  18.  virtex doesn't like filenames with blanks (and ARexx parses them
  19. hardly too), so avoid them in file, directory *and* device names.
  20.  *
  21. FILES:
  22.  ENV:TEXFORMAT: default format used
  23.  REXX:namestruc
  24.  *
  25. EXAMPLE: of ENV:TEXCONFIG(TeX:config/)ShowDVI.config (partial)
  26. f1        TeX:rexx/Start_TeX.sd        ; use default=last used
  27. f2        TeX:rexx/Start_TeX.sd plaine
  28. f3        TeX:rexx/Start_TeX.sd plaind
  29. f4        TeX:rexx/Start_TeX.sd latexgde
  30. f5        TeX:rexx/Start_TeX.sd ?        ; always ask for format
  31.  */
  32.  
  33. portname = 'Start_TeX'
  34. script     = 'TeX-server.rexx'
  35.  
  36. IF "" = GETCLIP("TEXQUERY") THEN askformat = 0
  37. ELSE askformat = 1        /* ask interactively for format name    */
  38.  
  39. OPTIONS RESULTS
  40. PARSE ARG format .
  41. IF "?" = format THEN DO
  42.     askformat= 1
  43.     format     = ""
  44.     END
  45. ELSE IF '&' = LEFT(format,1) THEN
  46.     format = SUBSTR(format,2)
  47.  
  48. getfile
  49. loadedfile = RESULT
  50. getdir
  51. loadeddir = RESULT
  52. IF RIGHT(loadeddir,1)~='/' & RIGHT(loadeddir,1)~=':' THEN
  53.     loadeddir = loadeddir||'/'
  54.  
  55. fullname = loadeddir||loadedfile
  56. PARSE VALUE namestruc(fullname) WITH ivol idirs ibase .
  57.  
  58. /* may be use GETCLIP("TEXFILE")? */
  59.  
  60. IF ".DVI" = UPPER(RIGHT(loadedfile,4)) THEN
  61.     fullname = OVERLAY(".tex", fullname, 1+ivol+idirs+ibase)
  62. ELSE    fullname = fullname||".tex"
  63.  
  64. IF 0 = ivol THEN DO
  65.     direc = PRAGMA('D')
  66.     IF RIGHT(direc,1)~='/' & RIGHT(direc,1)~=':' THEN direc=direc||'/'
  67.     fullname = direc||fullname
  68.     END
  69.  
  70. IF ~EXISTS(fullname) THEN DO
  71.     okay1 'Cannot find file 'fullname'!'
  72.     EXIT 10
  73.     END
  74.  
  75. IF SHOW('P',portname) THEN DO
  76.     /* set the default format, modify it to suit your needs */
  77.     envformat = mygetenv("TEXFORMAT")
  78.     IF "" == format THEN DO
  79.         format = envformat
  80.         IF askformat | "" = envformat THEN DO
  81.         IF "" = format THEN format = 'plain'
  82.  
  83.         'GetString 'format '"Which format to use ?"'
  84.         nformat = RESULT
  85.         /* "RESULT" if cancelled */
  86.         IF "RESULT" ~= nformat THEN format = nformat
  87.  
  88.         END /* askformat */
  89.         END /* format */
  90.  
  91.     if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
  92.  
  93.     message 'Calling TeX server with format 'format' and file 'fullname'.'
  94.     oldaddr = address()
  95.  
  96.     ADDRESS VALUE portname
  97.     'compile' format fullname
  98.     ADDRESS VALUE oldaddr
  99.     message 'TeX server called for file 'fullname'.'
  100.     END
  101. ELSE DO
  102.     okay1 'The TeX server in 'script' is not running !'
  103.     EXIT 10
  104.     END
  105. EXIT
  106.  
  107.  
  108. mygetenv: procedure    /* when will ARexx supply GetEnv/SetEnv ? */
  109.    PARSE ARG name
  110.  
  111.    IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
  112.     gives = readln(TEMPFILE)
  113.     CALL close TEMPFILE
  114.     END
  115.    ELSE gives = ""
  116.  
  117.    RETURN gives
  118.  
  119. mysetenv: procedure
  120.    PARSE ARG name,content
  121.  
  122.    ADDRESS COMMAND "SetEnv" name content
  123.  
  124.    RETURN
  125.