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

  1. /*RX
  2.  * AREXX    Name:Start_TeX.ced    Version:1.41    Date:27-Jul-91
  3.  *
  4.  This AREXX script saves and compiles the current CED view. The only
  5. (optional) argument is the format to be used. A '?' formatname will
  6. interactively ask for the format to use.
  7.  *
  8.  A command is send to the TeX server to compile the file. Hence a
  9. return value of 0 does not mean that the file compiled well, but only
  10. that the command was sent to the server and replied to.
  11.  *
  12. AUTHOR:
  13.  *    J\"org H\"ohle, March 91
  14.  *
  15. BUGS:
  16.  virtex doesn't like filenames with blanks (and ARexx parses them
  17. hardly too), so avoid them in file, directory *and* device names.
  18.  *
  19.  Does not like names relative to the local root, like ":foo/bar"
  20.  *
  21. FILES:
  22.  ENV:TEXFORMAT: default format used
  23.  REXX:namestruc
  24.  *
  25.  */
  26.  
  27. /* OPTIONS FAILAT 3 */
  28.  
  29. /**
  30. IF ~SHOW('L','rexxsupport.library') THEN
  31.     IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN DO
  32.         okay1 "Can't open 'rexxsupport.library'!"
  33.         EXIT 20
  34.         END
  35. **/
  36.  
  37. OPTIONS RESULTS
  38.  
  39. portname = 'Start_TeX'
  40. script     = 'TeX-server.rexx'    /* no path required, message only    */
  41.  
  42. IF "" = GETCLIP("TEXQUERY") THEN askformat = 0
  43. ELSE askformat = 1        /* ask interactively for format name    */
  44.  
  45. PARSE ARG format .
  46. IF "?" = format THEN DO
  47.     askformat= 1
  48.     format     = ""
  49.     END
  50. ELSE IF '&' = LEFT(format,1) THEN
  51.     format = SUBSTR(format,2)
  52.  
  53. status 19    /* full filename */
  54. fullname=RESULT
  55.  
  56. /* We need an absolute name */
  57. PARSE VALUE namestruc(fullname) WITH ivol idirs ibase .
  58.  
  59. IF "" == SUBSTR(fullname, 1+ivol+idirs+ibase) | UPPER(RIGHT(fullname,3)) ~= "TEX" THEN DO
  60.     okay1 "Sorry, filename must have an extension and end in `tex'."
  61.     EXIT 5
  62.     END
  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.     DROP direc
  69.     END
  70. DROP ivol idirs ibase
  71.  
  72. /* Save only if file has been modified */
  73. status 18    /* number of changes to the file */
  74. If 0 < RESULT THEN Save
  75.  
  76. IF (SHOW('P', portname)) THEN DO
  77.     /* set the default format, modify it to suit your needs */
  78.     envformat = mygetenv("TEXFORMAT")
  79.     IF "" == format THEN DO
  80.         format = envformat
  81.         IF askformat | "" = envformat THEN DO
  82.         IF "" = format THEN format = 'plain'
  83.  
  84.         'GetString 'format '"Which format to use ?"'
  85.         nformat=RESULT
  86.         /* "RESULT" if cancelled */
  87.         IF "RESULT" ~= nformat THEN format = nformat
  88.  
  89.         END /* askformat */
  90.         END /* format */
  91.  
  92.     /* If the server is already busy with some compilation, this will
  93.     wait till compilation finishes, this may take a long time */
  94.     /* no unlocking (like in MG) available */
  95.  
  96.     if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
  97.  
  98.     ADDRESS VALUE portname
  99.     'compile' format fullname
  100.     END
  101. ELSE DO
  102.     /* The TeX server must be started first */
  103.     Okay1 'The TeX server 'script' is not running !'
  104.     EXIT 5
  105.     END
  106. EXIT
  107.  
  108.  
  109. mygetenv: procedure    /* when will ARexx supply GetEnv/SetEnv ? */
  110.    PARSE ARG name
  111.  
  112.    IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
  113.     gives = readln(TEMPFILE)
  114.     CALL close TEMPFILE
  115.     END
  116.    ELSE gives = ""
  117.  
  118.    RETURN gives
  119.  
  120. mysetenv: procedure
  121.    PARSE ARG name,content
  122.  
  123.    ADDRESS COMMAND "SetEnv" name content
  124.  
  125.    RETURN
  126.