/*************************************************************************
* RCSshowlog.ttx:	Show the RCS change log in a buffer.
* 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: RCSshowlog 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.
*************************************************************************/

LOGFILE = "t:" || myfile || "_LOG"

ADDRESS COMMAND "rlog" RCSoptions myfile ">" LOGFILE
IF Word(statef(LOGFILE), 2) = 0 THEN
	CALL TellUser("No log found.")
ELSE DO
	OpenDoc NAME LOGFILE
	ADDRESS COMMAND "Delete" LOGFILE "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))
