/********************************************************************************/
/* ARexx program 	    TeXifyLookNext	V 1.01 (May 90)			*/
/*			( use with TeXify 1.04 or greater !! )			*/
/*										*/
/*				This program can only be used in conjunction	*/
/*				with     TeXify.      After    TeXify    use	*/
/* Copyright 1990		TeXifyLookNext for getting further TeX error	*/
/* by Wolf-Juergen Faust	reports.   For  a new TeXifyLookNext version	*/
/* Am Dorfgarten 10		call  FIDO  +(49)  6173  2544  (HST  DS)  or	*/
/* W-6000 Frankfurt 50		contact  me.  Don't spread this file without	*/
/* Germany			the additional readme and Arexx files !		*/
/* FIDO: 2:243/43.5 (Wolf Faust)						*/
/* UUCP: cbmvax.commodore.com!cbmehq!cbmger!venus!wfaust			*/
/* Tel: +(49) 69 5486556							*/
/*										*/
/* Versions needed:								*/
/* ARexx >= V 1.10  (tested: 1.10, 1.12, 1.14)					*/
/* CEDPro>= V 2.00  (tested: 2.10, 2.11, 2.12)					*/
/********************************************************************************/

/*** Return ***/
cr = '0A'X

/*** program receives answers ***/
options results

/*** now lets get to business with CygnusEd ***/
address 'rexx_ced'

/*** is there a log file ??? ***/
if ~exists('t:tex.log') then do
	okay1 "Ooops ! There is no errorfile !"
	exit
	end

/*** get number off errors done ***/
done = getclip("texlog")+1
/*** get path to main textfile ***/
path = getclip("texpath")
/*** get suffix of main textfile ***/
sfx = getclip("texsfx")

/*** search line with error description in t:tex.log ***/
rc = open('log','t:tex.log')
if rc = 0 then do
	okay1 "ERROR ! Can't open existing errorfile !"
	exit 5
	end
do lin = 1 for done
	logline = readln('log')
	if eof('log') then do
		/*** no more error found in file ***/
		call close 'log'
		okay1 "No more error found !"
		call delete("t:tex.log")
		exit 5
		end
	end
call close 'log'

parse var logline line pos filename cause
setclip("texlog",done)
strip (filename)
strip (cause)

if filename = "!" then do
	'jumpto' line pos
	okay1 "Ooops ! Error in unknown TeX source !"||cr||cause||cr||"Error in line:"||line||"  pos:" pos
	exit
	end
/*** this part looks strange, but there maybe strange filenames !! ***/
'jump to file' filename
if result = 0 then do
	if exists(path||filename) then do
		'open new'
		'open' path||filename
		'jumpto' line pos
		okay1 cause
		exit 5
		end
	if exists(filename) then do
		'open new'
		'open' filename
		'jumpto' line pos
		okay1 cause
		exit 5
		end
	'jump to file' filename||sfx
	if result = 0 then do
		if exists(path||filename||sfx) then do
			'open new'
			'open' path||filename||sfx
			'jumpto' line pos
			okay1 cause
			exit 5
			end
		if exists(filename||sfx) then do
			'open new'
			'open' path||filename||sfx
			'jumpto' line pos
			okay1 cause
			exit 5
			end
		'jumpto' line pos
		okay1 "Ooops ! Error in "||filename||"  TeX file !"||cr||cause||cr||"Error in line:"||line||"  pos:" pos
		exit 5
		end
	end
'jumpto' line pos
okay1 cause
