C!----------------------------------------------------------
	LOGICAL FUNCTION GET_LOGICAL(log_name,file_name,max_len
	1	,act_len,tbl_nam)
C
C Get a logical name definition for logical name log_name, 
C the translation (if any) is returned in file_name.
C The logical table name is specified by tbl_nam.
C
C Return code: 	.TRUE.  for successful translation
C 		.FALSE. if translation was not successful
C-----------------------------------------------------------
	include '($lnmdef)'
	include '($psldef)/list'
	character*(*) log_name,file_name,tbl_nam
	logical DEF_LOGICAL
	integer status,max_len,act_len,acc_mode,len
	integer SYS$TRNLNM,SYS$CRELNM,LIB$SET_LOGICAL 
C define a structure (yeck) to use SYS$TRNLNM or SYS$CRELNM
	STRUCTURE /UGH/
	  UNION
	   MAP
	    INTEGER*2 NUM_BYTES
	    INTEGER*2 CODE
	    INTEGER*4 LOC_STR
	    INTEGER*4 LOC_STR_LEN
	   ENDMAP
	   MAP
	    INTEGER*4 END_OF_LIST
	   ENDMAP
	  ENDUNION
	ENDSTRUCTURE
C Now give me one of them structure thingies
	RECORD /UGH/ WHERE(2)
C now fill it up
	WHERE(1).NUM_BYTES = max_len		! max # of chars to be returned
	WHERE(1).CODE = LNM$_STRING		! CODE ==> ret. name as string
	WHERE(1).LOC_STR = %LOC(file_name)	! where to put the string
	WHERE(1).LOC_STR_LEN = %LOC(act_len)	! where to put the string length
	WHERE(2).END_OF_LIST = 0		! that's all folks
C now go away and get it
	STATUS = SYS$TRNLNM (lnm$M_case_blind,
	1			tbl_nam,log_name,,where)
	IF (STATUS) then 
	  GET_LOGICAL = .true.
	else
	  GET_LOGICAL = .false.
	endif
	return
C!--------------------------------------------------------------------
	ENTRY DEF_LOGICAL(log_name,file_name,act_len,acc_mode,tbl_nam)
C To define logical name log_name as file_name.
C The logical table name is specified by tbl_nam
C The access mode is defined by acc_mode:
C     	0	for user mode
C	other 	for supervisor mode. 
C (Note: this routine does not require SYSNAM privileges; it would be 
C simpler to assume SYSNAM, but that's cheating)
C
C Return code:	.TRUE.  for successful definition
C 		.FALSE. if definition was not successful
C---------------------------------------------------------------------
	if (acc_mode .eq. 0) then	! -- user mode definition
C find end of passed string
	  do i=act_len,1,-1
	    len = i
	    if (ichar(file_name(i:i)) .ne. 0 
	1	.and. file_name(i:i)  .ne. ' ') goto 1
	  enddo
C now fill up data structure
1	  WHERE(1).NUM_BYTES = len		! # of chars in string 
	  WHERE(1).CODE = LNM$_STRING		! CODE ==> def name from string
	  WHERE(1).LOC_STR = %LOC(file_name)	! where the string is
	  WHERE(1).LOC_STR_LEN = 0 		! not used 
	  WHERE(2).END_OF_LIST = 0		! that's all folks
C now go away and do it
	  STATUS = SYS$CRELNM (,tbl_nam,log_name,,where)
	else				! -- supervisor mode definition
	  STATUS = LIB$SET_LOGICAL (log_name,file_name,tbl_nam)
	endif
	IF (STATUS) then 
	  DEF_LOGICAL = .true.
	else
	  DEF_LOGICAL = .false.
	endif
	return
	end
C!--------------------------------------------------------------
	LOGICAL FUNCTION GET_NUMBER(parm,value)
C
C  Subroutine get an integer value for a qualifier or parameter
C---------------------------------------------------------------
	INTEGER LEN,value
	INTEGER STATUS,CLI$GET_VALUE
	CHARACTER*20 string,PARM*(*)

	get_number = .true.
	STATUS = CLI$GET_VALUE(parm,string,len)
C is there a valid parameter here?
	if (status .and. len .gt. 0) then 
C Convert character string to a number
	  read(unit=string(1:len),fmt='(I)',err=1) value
	  get_number = .false.
	endif
C	type *,parm,':  ',string(1:len),'(',len,')',value
1	return
	end
C!--------------------------------------------------------------
	LOGICAL FUNCTION GET_FNUMBER(parm,value)
C
C  Subroutine get an floating point value for a qualifier or parameter
C------------------------------------------------------------------
	INTEGER LEN
	REAL value
	INTEGER STATUS,CLI$GET_VALUE
	CHARACTER*20 string,PARM*(*)

	get_fnumber = .true.
	STATUS = CLI$GET_VALUE(parm,string,len)
C is there a valid parameter here?
	if (status .and. len .gt. 0) then 
C Convert character string to a number
	  read(unit=string(1:len),fmt='(f10.0)',err=1) value
	  get_fnumber = .false.
	endif
C	type *,parm,':  ',string(1:len),'(',len,')',value
1	return
	end
C!----------------------------------------------------------
	byte FUNCTION rem_zero(char)
	byte char
	if (char .eq. 0) then
	  rem_zero = 32
	else
	  rem_zero = char
	endif
	return
	end
