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

  1. /* Look at the command at the end of the script an change it accordingly to your
  2. TeX setup 
  3.  
  4. Done by:
  5.  
  6. R.Laederach
  7. Kappelisackerstr. 46
  8. 3063 Ittigen
  9. Switzerland
  10. Phone:+41/(0)31/912 19 08
  11.  
  12. This stuff ist PostcardWare, so send me a postcard or something useful (read
  13. the doc!).
  14. */
  15.  
  16. /* $VER: 0.9, ©1993 Dietmar Eilert. Empty GoldED macro */
  17.  
  18. OPTIONS RESULTS                             /* enable return codes     */
  19.  
  20. if (LEFT(ADDRESS(), 6) ~= "GOLDED") then    /* not started by GoldEd ? */
  21.     address 'GOLDED.1'
  22.  
  23. 'LOCK CURRENT'                              /* lock GUI, gain access   */
  24. OPTIONS FAILAT 6                            /* ignore warnings         */
  25. SIGNAL ON SYNTAX                            /* ensure clean exit       */
  26.  
  27.  
  28. /*** Look if DVIprint is already busy ***/
  29.  
  30. IF SHOW('P','dviprint') THEN DO
  31.     'REQUEST BODY="DVIprint is already running, please wait"'
  32.     UNLOCK
  33.     EXIT
  34.     END
  35.  
  36. /*** Look if the user forgot to state which printer to use ***/
  37.  
  38. noprinter = mygetenv("DVIPRINT")
  39.  
  40. IF noprinter=="" THEN DO
  41.     'REQUEST OLD="printer=" BODY="Use which printer and draft ?" STRING VAR PRINTER'
  42.     /* I hope you stated something reasonable */
  43.     CALL mysetenv("DVIPRINT",'"'printer'"') /* Look at that tricky construction !! */
  44. END 
  45.  
  46. CALL SETCLIP("pages")
  47.  
  48.  
  49. 'QUERY DOC'
  50. filename=RESULT
  51.  
  52. basename = (left(filename, LENGTH(filename)-4))
  53. extension = translate(right(filename, 4) , xrange('a','z'), xrange('A','Z'))
  54.  
  55.  
  56. /*** is there a .dvi file ? ***/
  57. IF ~EXISTS(basename||".dvi") THEN DO
  58.     'REQUEST BODY="The corresponding .dvi file does not exist|Use Start_TeX to generate one."'
  59.     UNLOCK 
  60.     EXIT 5
  61.     END
  62.  
  63. /*** I want to know if the customer wants to print the whole text ***/
  64.  
  65. 'REQUEST BODY="Print all pages ?" BUTTON="_Yep|_Nope"'
  66.    if (RESULT = 0) THEN DO
  67.         'REQUEST LONG TITLE="Print from which page ?" MIN=0 MAX=10000 VAR PAGEFROM'
  68.         IF pagefrom='' THEN DO
  69.            'REQUEST BODY="Enter a number!"'
  70.            UNLOCK
  71.            EXIT
  72.         END
  73.         'REQUEST LONG OLD="" TITLE="Print to which page ?" MIN=0 MAX=1000 VAR PAGETO'
  74.         IF pageto='' THEN DO
  75.            'REQUEST BODY="Enter a number!"'
  76.            UNLOCK
  77.            EXIT
  78.         END
  79.         'REQUEST STRING BODY="Print every (<RET>), ODD or EVEN pages?" VAR WHATPAGE'
  80.         IF whatpage = "" THEN
  81.         CALL SETCLIP("pages","FROM" pagefrom" TO "pageto" ")
  82.         else
  83.         CALL SETCLIP("pages","FROM" pagefrom" TO "pageto whatpage" ")
  84.         END
  85.  
  86.  
  87.  
  88.  
  89. /* now lets start the command given by the user and unlock GoldED */
  90.  
  91.  
  92. ADDRESS COMMAND "run >nil: <nil: tex:bin/DVIPRINT -l -p -r "||GETCLIP("pages")||basename
  93.  
  94. 'UNLOCK' /* VERY important: unlock GUI */
  95. EXIT
  96.  
  97. SYNTAX:
  98.  
  99. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  100. 'UNLOCK'
  101. EXIT
  102.  
  103.  
  104. mygetenv: procedure     /* when will ARexx supply GetEnv/SetEnv ? */
  105.    PARSE ARG name       /* Thanks to Georg ! */
  106.  
  107.    IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
  108.     gives = readln(TEMPFILE)
  109.     CALL close TEMPFILE
  110.     END
  111.    ELSE gives = ""
  112.  
  113.    RETURN gives
  114.  
  115. mysetenv: procedure
  116.    PARSE ARG name,content
  117.  
  118.    ADDRESS COMMAND "SetEnv" name content
  119.  
  120.    RETURN
  121.    END
  122.