home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
useful
/
text
/
tex
/
pastex
/
rexx
/
start_tex.mg
< prev
next >
Wrap
Text File
|
1991-07-27
|
3KB
|
111 lines
/*RX
* AREXX Name:Start_TeX.mg Version:1.41 Date:27-Jul-91
*
This AREXX script saves and compiles the current MicroGNUEmacs
buffer. 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.
*
FILES:
ENV:TEXFORMAT: default format used
*
*/
OPTIONS FAILAT 3
OPTIONS RESULTS
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)
'rexx-buffer' buf
/* buf.2 is the complete filename (beware of spaces) */
IF "TEX" ~= UPPER(RIGHT(buf.2,3)) THEN DO
/* more foolproof : use namestruc() to verify extension */
'rexx-display "Sorry, filename must end in `tex''."'
EXIT 5
END
'save-buffer'
/* fails if file is write protected */
IF (SHOW('P', portname)) THEN DO
envformat = mygetenv("TEXFORMAT")
IF "" = format THEN DO
format = envformat
IF askformat | "" = envformat THEN DO
IF "" = format THEN format = 'plain'
'rexx-request "Which format to use ? (default 'format') "'
/* 0: answered, 1: default, 2: abort(^G) */
IF 0 = RC THEN format = RESULT
ELSE IF 1 < RC THEN DO
'rexx-display ""'
EXIT 5
END
END /* askformat */
END /* !format */
if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
'rexx-display "Calling TeX server 'portname'."'
/* We want to free MG if the TeX server is just busy with
another file */
'rexx-unlock'
/* we free this MG port and get the name of a new one for later use */
freeMG = RESULT
ADDRESS VALUE portname
'compile' format buf.2
ADDRESS VALUE freeMG
'rexx-display "TeX server called for file 'buf.2'."'
END
ELSE DO
/* The TeX server must be started first */
'rexx-display "The TeX server 'script' is not running !"'
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