/*
 *	StartDVIprint.sd
 *
 * Invokes the TeXPrt program, a front-end for DVIPrint.
 *
NOTES:
 *
 * You must have set the printer name in ENV:DVIprint for this to
 * work, or the default (generic) printer will be used.
 *
 */

LF = '0A'X


OPTIONS RESULTS

getfile
loadedfile = RESULT
getdir
loadeddir = RESULT
getpage
page = RESULT

IF RIGHT(loadeddir,1)~='/' & RIGHT(loadeddir,1)~=':' THEN
	loadeddir = loadeddir||'/'

IF upper(right(loadedfile,4)) ~= ".DVI" THEN
	loadedfile = loadedfile||".dvi"

IF loadedfile = "" | ~exists(loadeddir||loadedfile) THEN DO
	Message "Which file should I print?"
	EXIT
	END

IF show('P','dviprint') THEN DO
	Message "DVIprint is already running, please wait"
	EXIT
	END

	Message "calling TeXPrt."

   ADDRESS COMMAND 'cd Tex:bin'
	ADDRESS COMMAND 'Tex:bin/TeXPrt APPICON="Tex:bin/TeXPrt"
                    SHELL="newshell CON:20/340/660/150/TeXPrint-Output/SCREENShowDVI-PubScr"
                    FILE='loadeddir||loadedfile
	IF 0~= RC THEN Message "TeXPrt failed."

EXIT
