C+
C NAME:
C	iSetDefaultDir
C PURPOSE:
C	Set new default diirectory (equivalent of 'cd' command)
C CATEGORY:
C	Environment
C CALLING SEQUENCE:
	function iSetDefaultDir(cNewDef)
C INPUTS:
C	cNewDef		character*(*)	name of new directory
C OUTPUTS:
C	(none)
C CALLS:
C	iGetDefaultDir, iGetFileSpec, iCheckDirectory, Say
C	iOSSetDirectory
C EXTERNAL:
C INCLUDE:
	include		'filparts.h'
C COMMON BLOCKS:
C SIDE EFFECTS:
C RESTRICTIONS:
C DEPENDENCY TREE:
C	iSetDefaultDir
C		Say
C		iGetFileSpec
C		iGetDefaultDir
C			iGetFilespec
C			iCheckDirectory
C		iCheckDirectory
C			iSetFileSpec
C			iGetFileSpec
C			iDir2File
C			iSearch
C		iOSSetDirectory *(system call)
C PROCEDURE:
C MODIFICATION HISTORY:
C	JUL-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C	   More documentation
C-
	    character	cNewDef *(*)

	character	cSay*13		/'SetDefaultDir'/

	character	cNewDir *80
	character	cNewDisk*40
	character	cDefDir *80
	character	cDefDisk*40

	iSetDefaultDir = 0

	if (iGetDefaultDir(cDefDir) .eq. 0) return	! Get old default dir
	I = iGetFileSpec(0,FIL__DEVICE,cDefDisk)	! Old Node+Device

	if (iCheckDirectory(cNewDef) .eq. 0) return	! New dir exists?
	I = iGetFileSpec(0,FIL__DIRECTORY,cNewDir)	! New Node+device+directory

	if (cNewDir .eq. cDefDir) then			! Old=New: show default
	    call Say(cSay,'I','Now in',cNewDir)
	    iSetDefaultDir = 1
	else
	    iSetDefaultDir = iOSSetDirectory(cNewDir)	! New Node+Device+Directory
	    if (iSetDefaultDir .eq. 1) then
		I = iGetFileSpec(0,FIL__DEVICE,cNewDisk) ! New Node+Device
		if (cNewDisk .ne. cDefDisk) call Say(cSay,'I','Jumped','to device '//cNewDisk)
	    end if
	end if

	return
	end
