home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / text / edit / macro / tex-scripts / start_tex.ged < prev    next >
Text File  |  1994-03-24  |  4KB  |  135 lines

  1. /*RX
  2.  * AREXX        Name:Start_TeX.ged      Version:2.00    Date:28-Feb-94
  3.  *
  4.  This AREXX script saves and compiles the current GoldED window. 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.  *   René Laederach, February 94
  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.  Although I can't think GoldED will ever do that.
  21.  *
  22. FILES:
  23.  ENV:TEXFORMAT: default format used
  24.  REXX:namestruc
  25.  *
  26. Done by:
  27.  
  28. R.Laederach
  29. Kappelisackerstr. 46
  30. 3063 Ittigen
  31. Switzerland
  32. Phone:+41/(0)31/912 19 08
  33.  
  34. This stuff ist PostcardWare, so send me a postcard or something useful (read
  35. the doc!).
  36.  */
  37.  
  38. /* $VER: 0.9, ©1993 Dietmar Eilert. Empty GoldED macro */
  39.  
  40. OPTIONS RESULTS                             /* enable return codes     */
  41.  
  42. if (LEFT(ADDRESS(), 6) ~= "GOLDED") then    /* not started by GoldEd ? */
  43.     address 'GOLDED.1'
  44.  
  45. 'LOCK CURRENT'                              /* lock GUI, gain access   */
  46. OPTIONS FAILAT 6                            /* ignore warnings         */
  47. SIGNAL ON SYNTAX                            /* ensure clean exit       */
  48.  
  49. portname = 'Start_TeX'
  50. script   = 'TeX-server.rexx'    /* no path required, message only       */
  51.  
  52. IF "" = GETCLIP("TEXQUERY") THEN askformat = 0
  53. ELSE askformat = 1              /* ask interactively for format name    */
  54.  
  55. PARSE ARG format .
  56. IF "?" = format THEN DO
  57.         askformat= 1
  58.         format   = ""
  59.         END
  60. ELSE IF '&' = LEFT(format,1) THEN
  61.         format = SUBSTR(format,2)
  62.  
  63. 'QUERY DOC'       /* full filename */
  64. filename=RESULT
  65.  
  66.  
  67. IF "" == filename | UPPER(RIGHT(filename,3)) ~= "TEX" THEN DO
  68.         'REQUEST TITLE="Beware!" BODY="Sorry, filename must have an extension and end in .tex."'
  69.         UNLOCK
  70.         EXIT 5
  71.         END
  72.  
  73. 'QUERY MODIFY'
  74.  
  75. if (RESULT = 'TRUE') THEN DO
  76.     'SAVE ALL'
  77.     END
  78.  
  79. IF (SHOW('P', portname)) THEN DO
  80.         /* set the default format, modify it to suit your needs */
  81.         envformat = mygetenv("TEXFORMAT")
  82.         IF "" == format THEN DO
  83.             format = envformat
  84.             IF askformat | "" = envformat THEN DO
  85.                 IF "" = format THEN format = 'plain'
  86.  
  87.                 'REQUEST TITLE="Question!" BODY="Which format to use ?" STRING VAR NFORMAT'
  88.                 IF "RESULT" ~= nformat THEN format = nformat
  89.  
  90.                 END /* askformat */
  91.             END /* format */
  92.  
  93.         if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
  94.  
  95.         'UNLOCK'
  96.         ADDRESS VALUE portname
  97.         'compile' format filename
  98.         EXIT 0 /* Do it here to avoid multiple "Waiting for command..." messages in TeX server window */
  99.         END
  100. ELSE DO
  101.         /* The TeX server must be started first */
  102.         'REQUEST TITLE="Warning!" BODY="The TeX server script is not running !"'
  103.         UNLOCK
  104.         EXIT 5
  105.         END
  106.  
  107. 'UNLOCK' /* VERY important: unlock GUI */
  108.  
  109. EXIT
  110.  
  111. SYNTAX:
  112.  
  113. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  114. 'UNLOCK'
  115. EXIT
  116.  
  117. mygetenv: procedure     /* when will ARexx supply GetEnv/SetEnv ? */
  118.    PARSE ARG name
  119.  
  120.    IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
  121.         gives = readln(TEMPFILE)
  122.         CALL close TEMPFILE
  123.         END
  124.    ELSE gives = ""
  125.  
  126.    RETURN gives
  127.  
  128. mysetenv: procedure
  129.    PARSE ARG name,content
  130.  
  131.    ADDRESS COMMAND "SetEnv" name content
  132.  
  133.    RETURN
  134.  
  135.