	LOGICAL FUNCTION DIR_VAL (DIRECTORY,RESULT) !	SUBROUTINE DIR_VAL
	CHARACTER*(*) DIRECTORY
	CHARACTER*(*) RESULT
C******************************************************************************
C***
C***	THIS FUNCTION RETURNS .TRUE. IF THE DIRECTORY SPECIFIED IS A VALID
C***	EXISTING DIRECTORY, OR .FALSE. IF IT IS NOT.
C***
C***	PARAMETERS :
C***
C***		DIRECTORY	(C*?)	DIRECTORY SPECIFICATION TO BE TESTED.
C***
C***		RESULT		(C*?) 	RESULTING DIRECTORY TRANSLATION.
C***
C******************************************************************************
C*MCT
C	EXTERNAL IODEF
	INCLUDE '($RMSDEF)'
	INCLUDE '($LIBDEF)'
C
C***	LOCAL VARIABLES
	INTEGER*4 STATUS
	CHARACTER*100 RES
	CHARACTER*100 DIR
	INTEGER*4 CONTEXT
C
C***	BEGIN
	I = INDEX (DIRECTORY,'.')
	J = INDEX (DIRECTORY,';')
	K = INDEX (DIRECTORY,']')
	IF ((J .NE. 0) .OR.
	1   (I .NE. 0 .AND. K .NE. 0 .AND. I .GT. K)) THEN
	    DIR_VAL = .FALSE.
            RETURN
	ELSE
	ENDIF
C
	DIR = DIRECTORY
	CONTEXT = 0
	L = LENGTH (DIR) 
	M = INDEX (DIR,':')
	IF (M .NE. 0 .AND. M .NE. L) THEN
	    IF (DIR(M+1:M+1) .NE. '[') THEN
		DIR_VAL = .FALSE.
		RETURN
	    ELSE
	    ENDIF
	ELSE
	ENDIF
	IF (DIR(1:1) .EQ. '[') THEN 
	    IF (DIR(L:L) .NE. ']') THEN
		DIR_VAL = .FALSE.
		RETURN
	    ELSE
	    ENDIF
	ELSE
	    IF (DIR(L:L) .NE. ':') THEN
		L = L + 1
		DIR(L:L) = ':'
	    ELSE
	    ENDIF
	ENDIF
C
	STATUS = LIB$FIND_FILE (DIR(1:L)//'*.*',RES,CONTEXT,,,,)
	CALL LIB$FIND_FILE_END (CONTEXT)
C
	DIR_VAL = .NOT. ((STATUS .EQ. RMS$_BUG_DDI) 
	1	  .OR.   (STATUS .EQ. RMS$_DEV) 
	2	  .OR.   (STATUS .EQ. RMS$_DIR) 
	3	  .OR.   (STATUS .EQ. RMS$_DNF))
C
	IF (DIR_VAL) THEN
	    I = INDEX (RES,']')
	    IF (I .NE. 0) THEN
	        RESULT = RES (1:I)
	    ELSE
		DIR_VAL = .FALSE.
	    ENDIF
	ELSE
	ENDIF
C
	RETURN
	END
