home *** CD-ROM | disk | FTP | other *** search
- /*RX
- * AREXX Name:Start_TeX.ced Version:1.41 Date:27-Jul-91
- *
- This AREXX script saves and compiles the current CED view. The only
- (optional) argument is the format to be used. A '?' formatname will
- interactively ask for the format to use.
- *
- A command is send to the TeX server to compile the file. Hence a
- return value of 0 does not mean that the file compiled well, but only
- that the command was sent to the server and replied to.
- *
- AUTHOR:
- * J\"org H\"ohle, March 91
- *
- BUGS:
- virtex doesn't like filenames with blanks (and ARexx parses them
- hardly too), so avoid them in file, directory *and* device names.
- *
- Does not like names relative to the local root, like ":foo/bar"
- *
- FILES:
- ENV:TEXFORMAT: default format used
- REXX:namestruc
- *
- */
-
- address "GOLDED.1"
- /* OPTIONS FAILAT 3 */
-
- /**
-
-
-
- IF ~SHOW('L','rexxsupport.library') THEN
- IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN DO
- 'REQUEST TITLE="Oh Shit!" BODY="Can't open rexxsupport.library!"'
- EXIT 20
- END
- **/
-
- OPTIONS RESULTS
- LOCK CURRENT
- portname = 'Start_TeX'
- script = 'TeX-server.rexx' /* no path required, message only */
-
- IF "" = GETCLIP("TEXQUERY") THEN askformat = 0
- ELSE askformat = 1 /* ask interactively for format name */
-
- PARSE ARG format .
- IF "?" = format THEN DO
- askformat= 1
- format = ""
- END
- ELSE IF '&' = LEFT(format,1) THEN
- format = SUBSTR(format,2)
-
- 'REQUEST HIDE=1'
-
- QUERY FILE /* full filename */
- filename=RESULT
- QUERY PATH
- pathname=RESULT
-
- 'REQUEST DEFAULT=1'
-
- /* We need an absolute name */
-
- IF "" == filename | UPPER(RIGHT(filename,3)) ~= "TEX" THEN DO
- 'REQUEST TITLE="Beware!" BODY="Sorry, filename must have an extension and end in tex."'
- UNLOCK
- EXIT 5
- END
-
- if (RIGHT(pathname,1)) ~= ":" THEN DO
- pathname = pathname||"/"
- END
-
- fullname=pathname||filename
-
- 'QUERY MODIFY'
-
- if (RESULT = 'TRUE') THEN DO
- SAVE ALL
- END
-
- IF (SHOW('P', portname)) THEN DO
- /* set the default format, modify it to suit your needs */
- envformat = mygetenv("TEXFORMAT")
- IF "" == format THEN DO
- format = envformat
- IF askformat | "" = envformat THEN DO
- IF "" = format THEN format = 'plain'
-
- 'REQUEST TITLE="Question!" BODY="Which format to use ?" STRING'
- nformat=RESULT
- /* "RESULT" if cancelled */
- IF "RESULT" ~= nformat THEN format = nformat
-
- END /* askformat */
- END /* format */
-
- /* If the server is already busy with some compilation, this will
- wait till compilation finishes, this may take a long time */
- /* no unlocking (like in MG) available */
-
- if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
-
- UNLOCK
- ADDRESS VALUE portname
- 'compile' format fullname
- END
- ELSE DO
- /* The TeX server must be started first */
- 'REQUEST TITLE="Warning!" BODY="The TeX server script is not running !"'
- UNLOCK
- EXIT 5
- END
- EXIT
-
-
-
- mygetenv: procedure /* when will ARexx supply GetEnv/SetEnv ? */
- PARSE ARG name
-
- IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
- gives = readln(TEMPFILE)
- CALL close TEMPFILE
- END
- ELSE gives = ""
-
- RETURN gives
-
- mysetenv: procedure
- PARSE ARG name,content
-
- ADDRESS COMMAND "SetEnv" name content
-
- RETURN
-