/*************************************************************************
* RCSchanges.ttx:	Show the RCS changes since the last check-in
* Author:		Daniel J. Barrett, barrett@cs.umass.edu
* Distribution:		Copyright 1994 Daniel J. Barrett.
*			This file is freely distributable provided it is
*			distributed in its entirety.
*
* Version:		$VER: RCSchanges 1.0 (04.06.94)
* Version history:
*	1.0 (04.06.94):	Initial release
*************************************************************************/

OPTIONS RESULTS

/*************************************************************************
* Get any RCS options.
*************************************************************************/

PARSE ARG RCSoptions

/*************************************************************************
* Open rexxsupport.library.
*************************************************************************/

IF ~show('L', 'rexxsupport.library') THEN DO
	IF ~addlib('rexxsupport.library', 0, -30, 0) THEN DO
		SAY "Cannot open rexxsupport.library"
		EXIT
	END
END

/*************************************************************************
* Get the directory name and the filename.
*************************************************************************/

GetFilePath
IF RC ~= 0 THEN DO
	CALL ReportError("Cannot locate this file's path")
	EXIT 5
END
myfile	= FileOf(RESULT)


/*************************************************************************
* Open the log as a normal document.
*************************************************************************/

CHANGEFILE = "t:" || myfile || "_CHANGES"

ADDRESS COMMAND "rcsdiff" RCSoptions myfile ">" CHANGEFILE
IF Word(statef(CHANGEFILE), 2) = 0 THEN
	CALL TellUser("No changes")
ELSE DO
	OpenDoc NAME CHANGEFILE
	ADDRESS COMMAND "Delete" CHANGEFILE "FORCE"
END

EXIT

/*************************************************************************
* Return a file's unqualified name, given the fully qualified name.
* Return "" if there is none.
*************************************************************************/

FileOf: PROCEDURE
	PARSE ARG pathname
	here = LastPos("/", pathname)
	IF here = 0 THEN
		here = LastPos(":", pathname)
	IF here = 0 THEN
		RETURN("")
	ELSE
		RETURN(SubStr(pathname, here+1))

/*************************************************************************
* Report an error to the user.
*************************************************************************/

ReportError: PROCEDURE
	PARSE ARG msg
	BeepScreen
	SetStatusBar TEMPORARY msg
	RETURN

/*************************************************************************
* Report a non-error message to the user.
*************************************************************************/

TellUser: PROCEDURE
	PARSE ARG msg
	SetStatusBar TEMPORARY msg
	RETURN
