/*
** DelError.ced
**
** $VER: DelError.ced 1.0.1 (07.07.93)
**
** This script deletes the current error entry from scmsg's error
** buffer, thus moving on to the next error entry if there is one.
** Then it loads in the file(s) related to that entry and moves the
** cursor to the line number(s) relevant to the error, also
** displaying the error message in CygnusEd's message title bar.
**
** This script requires CygnusEd Professional v3.5 (or later) to run.
**
** SAS/C is a registered trademark of SAS Institute, Inc.
**
** Copyright © 1993 ASDG, Incorporated  All Rights Reserved
*/

/* If scmsg is not running, I guess there are no errors, so reset the title bar. */

IF ~SHOW('P', 'SC_SCMSG') THEN DO
    ADDRESS 'rexx_ced' DM
    EXIT 0
END


ADDRESS 'SC_SCMSG'

OPTIONS RESULTS

/*
** See if the message file is already empty.
*/

'FILE'
OLDFILE = RESULT
IF OLDFILE = "" THEN DO
	/*
	** If the message file is empty, clear Ced's message bar and terminate scmsg.
	*/

	ADDRESS 'rexx_ced' DM
	ADDRESS 'SC_SCMSG' QUIT
	EXIT 0
END


/*
** Delete the current message in scmsg.
*/

DELETE


/*
** Grab the file name, line number, error message etc. associated with the current error.
*/

'FILE'
FILE = RESULT

'LINE'
LINE = RESULT

'TEXT'
TEXT = RESULT

'ALTFILE'
ALTFILE = RESULT

'ALTLINE'
ALTLINE = RESULT

OPTIONS

ADDRESS 'rexx_ced'

IF FILE = "" THEN
	DM 'No more errors'
ELSE DO
	/*
	** If there is an alternate file, load it in first, so that
	** the cursor ends up in the main error file.
	*/

	IF ALTFILE ~= "" THEN DO
		OW ALTFILE
		LL ALTLINE
	END
	OW FILE
	LL LINE
	DM TEXT
END

EXIT 0
