C+
C NAME:
C	iSetSymbol
C PURPOSE:
C	Portable way of setting 'symbol' values
C CALLING SEQUENCE:
	function iSetSymbol(cName,cValue,iTable)
C INPUTS:
C	cName		character*(*)		name of symbol
C	cValue		character*(*)		value to be assigned to symbol
C	iTable		integer			not used (maintained for backward
C						compatibility with VMS version)
C OUTPUTS:
C	iSetSymbol	integer			0: failed to set symbol
C						1: succesful setting symbol
C SEE ALSO:
C	iGetSymbol, iDeleteSymbol, iSetLogical, iGetLogical, iDeleteLogical
C MODIFICATION HISTORY:
C	???-????, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	    character	cName *(*)
	    character	cValue*(*)
	    integer	iTable

	logical		bfirst		/.TRUE./
	save		bfirst

	if (bfirst) then
	    !write (*,'(A)') '%iSetSymbol-I-LOGFIL.TXT, not implemented'
	    bfirst = .FALSE.
	end if

	iSetSymbol = 0

	return
	end
C+
C NAME:
C	iGetSymbol
C PURPOSE:
C	Portable way of retrieving 'symbol' values
C CALLING SEQUENCE:
	function iGetSymbol(cName,cValue)
C INPUTS:
C	cName		character*(*)		name of symbol
C OUTPUTS:
C	iGetSymbol	integer			0: failed to get value of symbol
C						1: succesful getting value of symbol
C	cValue		character*(*)		value of symbol
C SEE ALSO:
C	iSetSymbol, iDeleteSymbol, iSetLogical, iGetLogical, iDeleteLogical
C MODIFICATION HISTORY:
C	???-????, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	    character	cName *(*)
	    character	cValue*(*)

	logical		bfirst		/.TRUE./
	save		bfirst

	if (bfirst) then
	    !write (*,'(A)') '%iGetSymbol-I-LOGFIL.TXT, not implemented'
	    bfirst = .FALSE.
	end if

	cValue = ' '
	iGetSymbol = 0

	return
	end
C+
C NAME:
C	iDeleteSymbol
C PURPOSE:
C	Portable way of deleting 'symbol' values
C CALLING SEQUENCE:
	function iDeleteSymbol(cName,iTable)
C INPUTS:
C	cName		character*(*)		name of symbol
C	iTable		integer			not used (maintained for backward
C						compatibility with VMS version)
C OUTPUTS:
C	iDeleteSymbol	integer			0: failed to delete symbol
C						1: succesful deleting symbol
C SEE ALSO:
C	iSetSymbol, iGetSymbol, iSetLogical, iGetLogical, iDeleteLogical
C MODIFICATION HISTORY:
C	???-????, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	    character	cName*(*)
	    integer	iTable

	logical		bfirst		/.TRUE./
	save		bfirst

	if (bfirst) then
	    !write (*,'(A)') '%iDeleteSymbol-I-LOGFIL.TXT, not implemented'
	    bfirst = .FALSE.
	end if

	iDeleteSymbol = 0

	return
	end
C+
C NAME:
C	iSetLogical
C PURPOSE:
C	Portable way of setting 'logical' values
C CALLING SEQUENCE:
	function iSetLogical(cName,cValue,cTable)
C INPUTS:
C	cName		character*(*)		name of logical
C	cValue		character*(*)		value to be assigned to logical
C	cTable		character*(*)		not used (maintained for backward
C						compatibility with VMS version)
C OUTPUTS:
C	iSetLogical	integer			0: failed to set logical
C						1: succesful setting logical
C SEE ALSO:
C	iSetSymbol, iGetSymbol, iDeleteSymbol, iGetLogical, iDeleteLogical
C MODIFICATION HISTORY:
C	???-????, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	    character	cName *(*)
	    character	cValue*(*)
	    character	cTable*(*)

	character cDum		! Dummy to avoid compiler warning

	logical		bfirst		/.TRUE./
	save		bfirst

	if (bfirst) then
	    !write (*,'(A)') '%iSetLogical-I-LOGFIL.TXT, not implemented'
	    bfirst = .FALSE.
	end if

	iSetLogical = 0

	return
	end
C+
C NAME:
C	iGetLogical
C PURPOSE:
C	Portable way of retrieving 'logical' values
C CALLING SEQUENCE:
	function iGetLogical(cName,cValue)
C INPUTS:
C	cName		character*(*)		name of logical
C OUTPUTS:
C	iGetLogical	integer			0: failed to get value of logical
C						1: succesful getting value of logical
C	cValue		character*(*)		value of logical
C INCLUDE:
	include		'filparts.h'
	include   	'dirspec.h'
C CALLS:
C	itrim, iUniqueName, iOSSpawnCmd, iGetLun, iFreeLun
C SEE ALSO:
C	iSetSymbol, iGetSymbol, iDeleteSymbol, iSetLogical, iDeleteLogical
C MODIFICATION HISTORY:
C	???-????, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	    character	cName *(*)
	    character	cValue*(*)

	character	cFile*(FIL__LENGTH)
	character	cRec *(FIL__LENGTH)

	parameter	(NSET = 100)
	character	cSet(NSET)*(FIL__LENGTH)
	save		cSet

	integer		iLast
	save		iLast

	integer		iSet		/0/
	save		iSet

	iGetLogical = itrim(cName)

	if (iGetLogical .gt. 0) then

	    if (cName .eq. '#next_name#') then

		if (iSet .eq. 0) then

		    cFile = ' '
		    call getenv('TUB',cFile)
		    if (cFile .eq. ' ') call getenv('HOME',cFile)
		    cFile(itrim(cFile)+1:) = cTrail(:iTrail)//'set?.tmp'
		    i = iUniqueName(cFile,cFile)
		    i = iOSSpawnCmd('set > '//cFile(:i),0)

		    iU = iGetLun(cFile)
		    open (iU, file=cFile, status='unknown')

		    iSet = 0
		    read (iU,'(A)',iostat=i) cRec
		    do while (i .eq. 0)
			i = index(cRec,'=')
			if (i .ne. 0 .and. i .lt. itrim(cRec)) then
			    if (cRec(i+1:i+1) .eq. cDivide) then
				if (iSet .eq. NSET) then
				    write (*,*) 'iGetLogical, not all env vars processed'
				else
				    iSet = iSet+1
				    cSet(iSet) = cRec
				end if
			    end if
			end if
			read (iU,'(A)',iostat=i) cRec
		    end do

		    iU = iFreeLun(-iU)
		    iLast = 0

		end if

		iLast = iLast+1

		if (iLast .le. iSet) then
		    cRec = cSet(iLast)
		    i = index(cRec,'=')
		    cName  = cEnvi(:iEnvi)//cRec(:i-1)
		    cValue = cRec(i+1:)
		    iGetLogical = 1
		else
		    iLast  = 0
		    cName  = ' '
		    cValue = ' '
		    iGetLogical = 0
		end if

	    else

		i = index(cName,cEnvi(:iEnvi))
		if (i .ne. 1) i = 0
		cRec = ' '
		call getenv(cName(i+1:),cRec)
		iGetLogical = min(itrim(cRec),1)
		if (iGetLogical .ne. 0) cValue = cRec

	    end if

	end if

	if (iGetLogical .eq. 0) then

	    cValue = ' '

	else
	    iGetLogical = itrim(cValue)

	    ! KLUDGE: cTemp and cHome are directories and should be defined with
	    ! a trailing backslash (on NT) or slash (on Unix). If there is no
	    ! trailing (back)slash functions like MkTmpFile will get into trouble.

	    !if (cName .eq. cHome .or. cName .eq. cEnvi//cHome .or.
     &		!cName .eq. cTemp .or. cName .eq. cEnvi//cTemp) then
		!if (cValue(iGetLogical:iGetLogical) .ne. cTrail) then
		    !cValue(iGetLogical+1:) = cTrail
		    !iGetLogical = iGetLogical+iTrail
		!end if
	    !end if

	end if

	return
	end
C+
C NAME:
C	iDeleteLogical
C PURPOSE:
C	Portable way of deleting 'logical' values
C CALLING SEQUENCE:
	function iDeleteLogical(cName)
C INPUTS:
C	cName		character*(*)		name of symbol
C OUTPUTS:
C	iDeleteLogical	integer			0: failed to delete logical
C						1: succesful deleting logical
C SEE ALSO:
C	iSetSymbol, iGetSymbol, iDeleteSymbol, iSetLogical, iGetLogical
C MODIFICATION HISTORY:
C	???-????, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
C-
	    character	cName*(*)

	logical		bfirst		/.TRUE./
	save		bfirst

	if (bfirst) then
	    !write (*,'(A)') '%iDeleteLogical-I-LOGFIL.TXT, not implemented'
	    bfirst = .FALSE.
	end if

	iDeleteLogical = 0

	return
	end
