	function auto_check_value(auto_info,line,kar,
     1                            ptr_entity,
     1                            partial,idx,
     1                            value,nk_value,
     1                            ptr_entity_res,
     1                            override,pos,forward,
     1                            negated)
	implicit none
c
c Line contains the (update) input string.
c  Check line for a valid value depending on the entity type
c kar contains the inserted character
c
c Depending on partial we take the following action
c 'E'   Input : Line  : the pattern to match
c             : Idx   : The idx' match
c             : pos   : The index of the cursor in the field
c       Output
c             : nk_value : >=0 on success, <0 for not found
c             : value    : the string
c             : pos      : if set to <0, new full contents
c
c 'P'   Input : Line : updated string
c               kar  : The character inserted
c      Output : nk_value : >=0 if valid
c                          -2  if not and kar cannot be a terminator   
c                          -1  if not valid and kar maybe a terminator 
c
c 'L' : Input : Line : the current string
c         display a help string for all values matching line
c
c 'F' : Input : line : the string entered
c      Output : nk_value : >=0 if valid
c                          <0 is not valid
c               value    : If valid, update value
c
c	include 'auto.inc'
	include 'table.inc'
c
	record /auto_info/ auto_info	!:i: terminal info
	character*(*) line			!:i: the line to match
	character kar				!:i: the character to be inserted
	integer*4 ptr_entity			!:i: the ptr to the entity
	character*(*) partial			!:i: match type (p/f/e)
	integer*4 idx				!:i: the idx'th match
	character*(*) value			!:o: value found
	integer*4 nk_value			!:o: #chars
	integer*4 ptr_entity_res		!:o: ptr to found item
	integer*4 override			!:i: force string type to another if >0
	integer*4 pos				!:i: position in string
	logical*4 forward			!:i: forward expand?
	logical*4 negated			!:o: keyword was negated
	integer*4 auto_check_value		!:f: function result
c#
c
	integer*4 auto_check_value_user_type
	integer*4 auto_check_value_string
	integer*4 auto_check_value_infile
	integer*4 auto_check_value_outfile
	integer*4 auto_check_value_number
	integer*4 auto_check_value_privilege
	integer*4 auto_check_value_datetime
	integer*4 auto_check_value_deltatime
	integer*4 auto_check_value_protection
	integer*4 auto_check_value_process
	integer*4 auto_check_value_inlog
	integer*4 auto_check_value_outlog
	integer*4 auto_check_value_insym
	integer*4 auto_check_value_outsym
	integer*4 auto_check_value_node
	integer*4 auto_check_value_device
	integer*4 auto_check_value_directory
	integer*4 auto_check_value_uic
	integer*4 auto_check_value_restofline
	integer*4 auto_check_value_parenvalue
	integer*4 auto_check_value_quotedstr
	integer*4 auto_check_value_file
	integer*4 auto_check_value_expression
	integer*4 auto_check_value_acl
c       
	integer*4 istat,value_type,ent_user,nk
	integer*4 def_des(2)
	logical*4 special_kar
	character*40 dbgline
c
	integer*4 table_entity_type
	integer*4 table_entity_user_type
c
	character*(*) default_file
	parameter (default_file = '*.*')
c
c Get the flags of the current entity
c
	negated = .false.
c
	call table_get_default(ptr_entity,def_des)
c
	value_type = table_entity_type(ptr_entity)
c
	ent_user = table_entity_user_type(auto_info.ptr_table_info,ptr_entity)
c
	if(override .ge. 0) then
c
c Only string types can be overriden
c
	  value_type = override
	  call table_get_type_name(value_type,dbgline,nk)
	  call terminal_debug(auto_info.ptr_terminal_info,
     1           'Overriding to '//dbgline(1:nk),0,dbg_flag_inp)
	   
	endif
c        
	special_kar = index('()/=, ',kar) .ne. 0
c
	ptr_entity_res = 0
c
c Now let each routine check for the buildup string
c
	if(ent_user .ne. 0) then
c
c User type
c
	  istat = auto_check_value_user_type(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value,
     1                    ent_user,ptr_entity_res,negated)
	elseif(value_type .eq. entity_block_valtyp_string) then
	  istat = auto_check_value_string(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_infile) then
	  if(def_des(1) .eq. 0) then
	    def_des(1) = len(default_file)
	    def_des(2) = %loc(default_file)
	  endif
	  istat = auto_check_value_infile(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value,def_des)
	elseif(value_type .eq. entity_block_valtyp_outfile) then
	  if(def_des(1) .eq. 0) then
	    def_des(1) = len(default_file)
	    def_des(2) = %loc(default_file)
	  endif
	  istat = auto_check_value_outfile(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value,def_des)
	elseif(value_type .eq. entity_block_valtyp_number) then
	  istat = auto_check_value_number(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_privilege) then
	  istat = auto_check_value_privilege(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_datetime) then
	  istat = auto_check_value_datetime(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value,pos,forward)
	elseif(value_type .eq. entity_block_valtyp_protection) then
	  istat = auto_check_value_protection(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_process) then
	  istat = auto_check_value_process(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_inlog) then
	  istat = auto_check_value_inlog(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_outlog) then
	  istat = auto_check_value_outlog(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_insym) then
	  istat = auto_check_value_insym(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_outsym) then
	  istat = auto_check_value_outsym(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_node) then
	  istat = auto_check_value_node(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_device) then
	  istat = auto_check_value_device(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_directory) then
	  istat = auto_check_value_directory(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_uic) then
	  istat = auto_check_value_uic(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_restofline) then
	  istat = auto_check_value_restofline(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_parenvalue) then
	  istat = auto_check_value_parenvalue(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_deltatime) then
	  istat = auto_check_value_deltatime(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value,pos,forward)
	elseif(value_type .eq. entity_block_valtyp_quotedstr) then
	  istat = auto_check_value_quotedstr(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_file) then
	  istat = auto_check_value_file(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_expression) then
	  istat = auto_check_value_expression(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_acl) then
	  istat = auto_check_value_acl(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	elseif(value_type .eq. entity_block_valtyp_old_file) then
	  istat = auto_check_value_file(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	else
c
c Unknown type, use string
c
	  istat = auto_check_value_string(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	endif
c
90	auto_check_value = istat
	return
	end
c
	function auto_check_value_user_type(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value,
     1                    ent_user,ptr_entity,negated)
	implicit none
c
c  Check function for user defined type 
c  returns nk_value <>0 for valid result, <0 for not found
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length (0 is not found)
	integer*4 ent_user			!:i: the pointer to the user types
	integer*4 ptr_entity			!:o: the entity selected
	logical*4 negated			!:o: true if negated match
	integer*4 auto_check_value_user_type
c
	integer*4 istat,k,ent_user_work
c
	integer*4 table_list_user
	integer*4 auto_help_add
	integer*4 auto_help_display
c
	integer*4 auto_msg
	external auto_msg_ambigk
	external auto_msg_invkey
c
c Check if the 
c 
	istat = ichar(kar)		!to prevent not-used warnings
	istat = 1
	if(partial .eq. 'E') then 
c
c Check for expand, try all user defined keywords
c  and see if the 'idx'th is present
c
	  if(idx .ge. 0) then
	    k = idx
            ent_user_work = ent_user
            do while(table_list_user(auto_info.ptr_table_info,
     1                         ent_user_work,
     1                         line,
     1                         value,nk_value,ptr_entity,
     1                         negated))
              k = k - 1
              if(k .eq. 0) goto 90
            end do
	  endif
	  nk_value = -1
	elseif(partial .eq. 'L') then 
c
c Just print help
c
          ent_user_work = ent_user
          do while(table_list_user(auto_info.ptr_table_info,
     1                         ent_user_work,
     1                         line,
     1                         value,nk_value,ptr_entity,
     1                         negated))
	    if(.not. auto_help_add(auto_info.ptr_terminal_info,
     1                value(1:nk_value))) goto 34
          end do
34	  istat = auto_help_display(auto_info.ptr_terminal_info,'Type')
	elseif(partial .eq. 'F') then
c
c See if line matches
c
          ent_user_work = ent_user
	  k = 0
          do while(table_list_user(auto_info.ptr_table_info,
     1                         ent_user_work,
     1                         line,
     1                         value,nk_value,ptr_entity,
     1                         negated))
            k = k + 1
          end do
c
c if F We must have only one match, 
c
	  if(k .gt. 1) goto 80
	  if(k .eq. 0) goto 85
	  nk_value = len(line)
	elseif(partial .eq. 'P') then
c
c See if line matches
c
	  if(special_kar) then
	    nk_value = -1
	  else
            ent_user_work = ent_user
	    k = 0
            do while(table_list_user(auto_info.ptr_table_info,
     1                         ent_user_work,
     1                         line,
     1                         value,nk_value,ptr_entity,
     1                         negated))
              k = k + 1
            end do
c
c if F We must have only one match, 
c
	    if(k .eq. 0) goto 85
	    nk_value = len(line)
	  endif
	endif
	goto 90
80	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_ambigk,line)
	nk_value = -1
	goto 90
85	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invkey,line)
	nk_value = -1
	goto 90
90	auto_check_value_user_type = istat
	return
	end
	function auto_check_value_string(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for user type (string)
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_string
c
	integer*4 istat,k
	integer*4 auto_msg
	logical in_quote
	external auto_msg_inpval
	external auto_msg_inquote
c
c See about the quote state
c
	in_quote = .false.
	istat = ichar(kar)		!to prevent not-used warnings
	istat = idx			!to prevent not-used warnings
	istat = 1
c
	if(partial .eq. 'E') then
	  do k=1,len(line)
	    if(line(k:k) .eq. '"') in_quote = .not. in_quote 
	  end do
c
c Auto fill the quote (if needed)
c
	  if(in_quote) then
	    value = line//'"'
	    nk_value = len(line) + 1
	  else
	    value = line
	    nk_value = len(line)
	  endif
	elseif(partial .eq. 'P' .or. partial .eq. 'F') then
c
c  Partial/full check, check for valid characters
c  
	  nk_value = len(line)
	  in_quote = .false.
c
	  do k=1,len(line)
	    if(line(k:k) .eq. '"') in_quote = .not. in_quote 
	    if(.not. in_quote) then
	      if(special_kar) then
	        nk_value = -1
	        goto 90
	      endif
	    endif
	  enddo
c
c Still quote open
c
	  if(partial .eq. 'F') then
	    if(in_quote) then
	      istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inquote)
	      if(.not. istat) goto 90
	      nk_value = -1
	    endif
	  endif
c
c For F check and all oke : return value
c
	  if(partial .eq. 'F' .and. nk_value .gt.0) value = line
	elseif(partial .eq. 'L') then
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1            %descr('string'))
	endif
90	auto_check_value_string = istat
	return
	end
c
	function auto_check_value_infile(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value,def_name)
	implicit none
c
c  Check function for $infile
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to insert
	logical*4 special_kar			!:i: special kar
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	character*(*) def_name			!:i: default name
	integer*4 auto_check_value_infile
c
	integer*4 istat,tel,context,kstat,ipos,last_dot,epos
	integer*4 first_br
	logical wild
c
	integer*4 get_len
	integer*4 auto_msg
	integer*4 auto_help_add
	integer*4 auto_help_display
	integer*4 lib$find_file
	external auto_msg_ambigp
	external auto_msg_invfile
	external auto_msg_filnotf
	logical*4 auto_check_filename
	integer*4 auto_check_dir_help
	logical*4 auto_check_dir_parse
c
	character*255 old_dir
	integer*4 nbr
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = 1
	context = 0
	tel = idx
c
	if(partial .eq. 'F') then
	  wild = index(line,'*') .ne. 0 .or. 
     1           index(line,'%') .ne. 0
	  kstat = lib$find_file(line,value,context,def_name)
	  if(kstat) then
c
c We found a file, if not wild this must be the only one
c
	    if(.not. wild) then
	      kstat = lib$find_file(line,old_dir,context,def_name)
              if(kstat) then
	        istat = auto_msg(auto_info.ptr_terminal_info,
     1                           auto_msg_ambigp,line)
	        nk_value = -1
	        goto 80
	      endif
	    endif
c
c Now return the original value
c  this is to prevent dir * to expand to one file
c  If the user wants expand, he must enter the expand(tab) command
c
	    value = line
	    nk_value = get_len(value)
	  else
	    istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_filnotf,line)
	    nk_value = -1
	  endif
	elseif(partial .eq. 'P') then
c
c Does the filename comply to vms file names
c
	  if(special_kar) then
	    nk_value = -1
	  else
	    if(auto_check_filename(line,.true.,.false.)) then
	      nk_value = len(line)
	    else
	      nk_value = -1
	    endif
	  endif
c
	elseif(partial .eq. 'L') then
c
c  Help
c    if in directory : return a list of deeper directories
c    if in filename  : return a list pf filenames
c
	  if(.not. auto_check_dir_parse(line,nbr,last_dot,first_br)) then
	    nk_value = -1
	    goto 90
	  endif
	  if(nbr .gt. 0) then
	    call auto_check_dir_help(line,last_dot,first_br,
     1                               auto_info.ptr_terminal_info)
	  else
	    do while(lib$find_file(line//'*;0',value,context,def_name))
	      nk_value = get_len(value)
	      call auto_file_parse(value(1:nk_value),'N',ipos,epos)
	      if(.not. auto_help_add(auto_info.ptr_terminal_info,
     1                               value(ipos:nk_value))) goto 34
	    enddo
	  endif
34	  istat = auto_help_display(auto_info.ptr_terminal_info,'File')
	elseif(partial .eq. 'E') then
c
c Expand : If in doirectory : expand deeper directory level
c          if in file       : expand the filename
c
	  nk_value = -1
	  if(idx .ge. 0) then
	    if(.not. auto_check_dir_parse(line,nbr,last_dot,first_br)) 
     1                  goto 90
c
c We are in de deeper directory, list all directories
c
	    if(nbr .gt. 0) then
	      call auto_check_dir_expand(line,value,idx,last_dot,
     1                                   first_br,nk_value)
	    else
10	      kstat = lib$find_file(line//'*.*',value,context,def_name)
	      if(kstat) then
	        tel = tel - 1	  
                if(tel .gt. 0) goto 10
	        nk_value = get_len(value)
	      endif
	    endif
	  endif
	endif
80	call lib$find_file_end(context)
90	auto_check_value_infile = istat
	return
	end
c
	function auto_check_value_outfile(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value) !,def_file)
	implicit none
c
c  Check function for $outfile
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
c	character*(*) def_file			!:i: default file
	integer*4 auto_check_value_outfile
c
	integer*4 istat,kstat,last_dot
	integer*4 nbr,first_br
c
	integer*4 auto_check_filename
	integer*4 auto_msg
	integer*4 auto_help_display
	logical*4 auto_check_dir_parse
c
	external auto_msg_invfile
	external auto_msg_inpval
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = 1
c
c See if we are in a partial directory
c
	nk_value = -1
	if(.not. auto_check_dir_parse(line,nbr,last_dot,first_br)) then
	  goto 90
	endif
c
c Now nbr is directory depth
c last_dot points to last directory separator
c
	if(partial .eq. 'E') then
c
c See if we are in a directory, If so we can expand
c by listing all directories tha match
c if we have finished directory, we cannot help
c
	  if(nbr .eq. 1) then	 
c
c if nbr<>1, Either no directories, or a closed directory, or invalid
c  we cannot expand
c
c if nbr=1 We have a partial directory, make a machting filename
c
	    call auto_check_dir_expand(line,value,idx,last_dot,
     1                                 first_br,nk_value)
	  else
	    nk_Value = 1
	  endif
	elseif(partial .eq. 'P') then
	  if(special_kar) then
	    nk_value = -1
	  else
	    kstat = auto_check_filename(line,.true.,.false.)
	    if(kstat) then
	      nk_value = len(line)
	    else
	      nk_value = -1
	    endif
	  endif
	elseif(partial .eq. 'L') then
	  if(nbr .eq. 1) then
	    call auto_check_dir_help(line,last_dot,first_br,
     1                               auto_info.ptr_terminal_info)
	    istat = auto_help_display(auto_info.ptr_terminal_info,'directorie')
	  else
	    istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1              %descr('filename'))
	  endif
c
c No partial checking
c
	elseif(partial .eq. 'F') then
c
c Now do a parse
c
	  kstat = auto_check_filename(line,.false.,.false.)
	  if(.not. kstat) then
	    istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invfile,line)
	    nk_value = -1
	  else
	    nk_value = len(line)
	    value    = line
	  endif
	endif
90	auto_check_value_outfile = istat
	return
	end
	subroutine auto_check_dir_expand(line,value,idx,last_dot,
     1                                   first_br,nk_value)
	implicit none
c
c Tab through directory files
c
	character*(*) line	!:i: the input string
	character*(*) value	!:o: the name
	integer*4 idx		!:i: the 'idx' match is wanted
	integer*4 last_dot	!:i: position of last .
	integer*4 first_br	!:i: first [ seen
	integer*4 nk_value	!:o: result string
c
	integer*4 ipos,nk_fnam,k,ctx,l
	character*255 fnam_s
c
	integer*4 lib$find_file
	integer*4 get_len
c
	if(last_dot .eq. 0) then
c
c No dots yet, assume the toplevel is the [000000]
c
	  fnam_s = line(1:first_br)//'000000]'//line(first_br+1:)
	  nk_fnam = len(line) + 7
	else
	  fnam_s = line(1:last_dot-1)//']'//line(last_dot+1:)
	  nk_fnam = len(line) + 1 - 1
	endif
	k = idx
	ctx = 0
	do while(lib$find_file(fnam_s(1:nk_fnam)//'*.DIR;1',value,ctx))
	  k = k-1
	  if(k .eq. 0) then
c
c  We have a match, now convert the full name to a directory spec
c
	    nk_value = get_len(value)
c
c First remove the  [000000. part (if present)
c
	    ipos = index(value(1:nk_value),'[000000')
	    if(ipos .ne. 0) then
c
c We have 2 options
c  1: dsa0:[000000.dirnam]dirdeep.dir;
c  2: dsa0:[000000]dirdeep.dir
c  Remove the 000000. or 000000]
c  so the result will be
c  1: dsa0:[dirnam]dirdeep
c  2: dsa0:[dir.dirdeep
c
	      value = value(1:ipos)//value(ipos+8:)
	      nk_value = nk_value - 7
	    endif	          
c
c  Replace the closing ] with a . for a new directory level
c  If we had the case 2, there is no ]
c
	    l = 0
34	    ipos = index(value(l+1:),']')
	    if(value(ipos-1:ipos-1) .eq. '^') then
c
c Prev char was a ^, so skip this one
c
	      l = ipos+1
	      goto 34
	    endif
c
	    if(ipos .ne. 0) then	        
	      ipos = ipos + l
	      value(ipos:ipos) = '.'
	    endif
c
c Now the name is
c case 1 : dsa0:[dirnam.dirdeep.dir;1
c case 2 : dsa0:[dirdeep.dir;1
c See if dirdeep = 000000, if so skip this one
c
36	    if(value(nk_value-11:nk_value) .eq. '000000.DIR;1') then
	      if(value(nk_value-12:nk_value-12) .eq. '.' .or.
     1           value(nk_value-12:nk_value-12) .eq. '[') then

c
c Skip the toplevel 000000 dir
c               
	        k = k + 1
	        goto 33
	      endif
	    endif
c
c Now look back from the end for the . separating the name and the extension
c
	    do k=nk_value,1,-1
	      if(value(k:k) .eq. '.' .and. value(k-1:k-1) .ne. '^') then
	        nk_value = k-1
	        goto 90
	      endif
	    enddo
	  endif
33	end do
c
c Sorry not found
c
	nk_value = -1
90	return
	end
	subroutine auto_check_dir_help(line,last_dot,first_br,terminal_info)
	implicit none
c
	include 'auto.inc'
c
c Help for directory files
c
	character*(*) line	!:i: the input string
	integer*4 last_dot	!:i: position of last .
	integer*4 first_br	!:i: position of first [
	integer*4 terminal_info !:i: terminal control block
	
c
	integer*4 ipos,nk_fnam,ctx,nk_value
	character*255 fnam_s,value
c
	integer*4 lib$find_file
	integer*4 auto_help_add
c
	if(last_dot .eq. 0) then
c
c No dots yet, assume the toplevel is the [000000]
c
	  fnam_s = line(1:first_br)//'000000]'//line(first_br+1:)
	  nk_fnam = len(line) + 7
	else
	  fnam_s = line(1:last_dot-1)//']'//line(last_dot+1:)
	  nk_fnam = len(line) + 1 - 1
	endif
	ctx = 0
	do while(lib$find_file(fnam_s(1:nk_fnam)//'*.DIR;1',value,ctx))
c
c Now look back from the end for the . separating the name and the extension
c
	  ipos = index(value,']')
	  value = value(ipos+1:)
	  nk_value = index(value,'.')
	  if(value(1:nk_value-1) .ne. '000000') then
	    if(.not. auto_help_add(terminal_info,value(1:nk_value))) goto 34
	  endif
	end do
c
c No more found, display help line
c
34	return
	end
c
	function auto_check_value_number(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for $number
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_number
c
	integer*4 istat,k
c
	integer*4 ots$cvt_tz_l
	integer*4 ots$cvt_to_l
	integer*4 ots$cvt_tu_l
	integer*4 auto_msg
	external auto_msg_invnum
	external auto_msg_inpval
c
	integer*4 nk,bpos
	logical octal
	logical hex
	logical decimal
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = idx			!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	istat = 1
	nk = len(line)
c
	if(partial .eq. 'E') then
c
c We have no expand on number, return the input string
c
	  nk_value = -1
c
	elseif(partial .eq. 'L') then
c
c Help , output a help text
c	  
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1              %descr('(DCL) number'))
c
	elseif(partial .eq. 'P' .or. partial .eq. 'F') then
c
c We cannot expand, but al others should check
c
	  octal   = .false.
	  hex     = .false.
	  decimal = .true.
	  if(nk .eq. 1) then
	    if(line(1:1) .eq. '%') then
	      goto 10
	    else
c
c Now check the rest
c
	      if(line(1:1) .eq. '+' .or. line(1:1) .eq. '-') goto 10
	      bpos = 1
	    endif
	  elseif(nk .eq. 2) then
	    if(line(1:1) .eq. '%') then
	      octal   = line(2:2) .eq. 'O' .or. line(2:2) .eq. 'o'
              hex     = line(2:2) .eq. 'X' .or. line(2:2) .eq. 'x'
	      decimal = line(2:2) .eq. 'D' .or. line(2:2) .eq. 'd'
	      if(octal .or. hex .or. decimal) then
	        goto 10
	      else
	        goto 20
	      endif	   
	    else
	      bpos = 1
	      if(line(1:1) .eq. '+' .or. line(1:1) .eq. '-') bpos = 2
	    endif
	  else
	    if(line(1:1) .eq. '%') then
	      octal   = line(2:2) .eq. 'O' .or. line(2:2) .eq. 'o'
              hex     = line(2:2) .eq. 'X' .or. line(2:2) .eq. 'x'
	      decimal = line(2:2) .eq. 'D' .or. line(2:2) .eq. 'd'
	      if(octal .or. hex .or. decimal) then
	        bpos = 3
	      else
	        goto 20
	      endif	   
	    else
	      bpos = 1
	      if(line(1:1) .eq. '+' .or. line(1:1) .eq. '-') bpos = 2
	    endif
	  endif
c
c Now check from pos bpos
c
	  if(hex) then
	    istat = ots$cvt_tz_l(line(bpos:),k)
	  elseif(octal) then
	    istat = ots$cvt_to_l(line(bpos:),k)
	  elseif(decimal) then
	    istat = ots$cvt_tu_l(line(bpos:),k)
	  endif
	  if(.not. istat) goto 20
10	  nk_value = len(line)
c
c For F check and all oke : return value
c
	  if(partial .eq. 'F' .and. nk_value .gt.0) value = line
	  goto 90
20	  nk_value = -1
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invnum,line)
	endif
90	auto_check_value_number = istat
	return
	end
c
	function auto_check_value_privilege(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for $priv
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character*(*) partial			!:i: the mode to check P/E/F
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_privilege
c
	integer*4 istat
c
	character*(*) privnames
	parameter (privnames='CMKRNL|'//
     1                       'CMEXEC|'//
     1                       'SYSNAM|'//
     1                       'GRPNAM|'//
     1                       'ALLSPOOL|'//
     1                       'IMPERSONATE|'//
     1                       'DIAGNOSE|'//
     1                       'LOG_IO|'//
     1                       'GROUP|'//
     1                       'NOACNT|'//
     1                       'PRMCEB|'//
     1                       'PRMMBX|'//
     1                       'PSWAPM|'//
     1                       'SETPRI|'//
     1                       'SETPRV|'//
     1                       'TMPMBX|'//
     1                       'WORLD|'//
     1                       'MOUNT|'//
     1                       'OPER|'//
     1                       'EXQUOTA|'//
     1                       'NETMBX|'//
     1                       'VOLPRO|'//
     1                       'PHY_IO|'//
     1                       'BUGCHK|'//
     1                       'PRMGBL|'//
     1                       'SYSGBL|'//
     1                       'PFNMAP|'//
     1                       'SHMEM|'//
     1                       'SYSPRV|'//
     1                       'BYPASS|'//
     1                       'SYSLCK|'//
     1                       'SHARE|'//
     1                       'UPGRADE|'//
     1                       'DOWNGRADE|'//
     1                       'GRPPRV|'//
     1                       'READALL|'//
     1                       'IMPORT|'//
     1                       'AUDIT|'//
     1                       'SECURITY|'//
     1                       'ACNT|'//
     1                       'ALTPRI|'//
     1                       'DETACH')
c
	integer*4 k,nk,nf,nk1
	character*11 privname	!the longest
c
	integer*4 get_len
	integer*4 str$element
	integer*4 str$case_blind_compare
	integer*4 auto_msg
	integer*4 auto_help_add
	integer*4 auto_help_display
c
	external auto_msg_invpriv
	external auto_msg_ambigpr
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = 1
	nk = len(line)
c
	if(partial .eq. 'P') then
	  nk_value = -1
	  if(special_kar) goto 90
c
	  k = 0
	  do while(str$element(privname,k,'|',privnames))
	    nk1 = get_len(privname)
	    if(nk .le. nk1) then
	      if(str$case_blind_compare(line,privname(1:nk)) .eq. 0) then
	        nk_value = len(line)
	        goto 90
	      endif
	    endif
	    k = k + 1
	  end do
	elseif(partial .eq. 'L') then
	  k = 0
	  do while(str$element(privname,k,'|',privnames))
	    nk1 = get_len(privname)
	    if(nk .le. nk1) then
	      if(str$case_blind_compare(line,privname(1:nk)) .eq. 0) then
	        if(.not. auto_help_add(auto_info.ptr_terminal_info,
     1                   privname(1:nk1))) goto 34
	      endif
	    endif
	    k = k + 1
	  end do
34	  istat = auto_help_display(auto_info.ptr_terminal_info,'Privilege')
	  goto 90
	elseif(partial .eq. 'F') then
	  k = 0
	  nf = 0
	  do while(str$element(privname,k,'|',privnames))
	    nk1 = get_len(privname)
	    if(nk .le. nk1) then
	      if(str$case_blind_compare(line,privname(1:nk)) .eq. 0) then
	        nf = nf + 1
	      end if
	    endif
	    k = k + 1
	  end do
	  if(nf .eq. 0) goto 80
	  if(nf .eq. 1) then
c
c Return correct output
c
	    nk_value = nk
	    value = line
	    goto 90
	  endif
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_ambigpr,line)
	  nk_value = -1
	elseif(partial .eq. 'E') then
	  nf = 0
	  if(idx .ge. 0) then
	    do while(str$element(privname,k,'|',privnames))
	      nk1 = get_len(privname)
	      if(nk .le. nk1) then
	        if(str$case_blind_compare(line,privname(1:nk)) .eq. 0) then
	          nf = nf + 1
	          if(nf .eq. idx) then
	            value = privname
	            nk_value = get_len(privname)
	            goto 90
	          endif
	        endif
	      end if
	      k = k + 1
	    end do
	  endif
c
c Not found
c
	  nk_value = -1
	  goto 90
	endif
c
80	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invpriv,line)
	nk_value = -1
90	auto_check_value_privilege = istat
	return
	end
c
	function auto_check_value_datetime(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                     value,nk_value,pos,forward)
	implicit none
c
c  Check function for $datetime 
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 pos				!:io: the position
	logical*4 forward			!:i: forward expand?
	integer*4 auto_check_value_datetime
c
	include '($libdtdef)'
c
	integer*4 istat,date(2),flag,n,k,flags,inc_date(2)
	integer*2 numtim(7)
	character*23 datetime
c
	integer*4 lib$convert_date_string
	integer*4 auto_msg
	external auto_msg_invdat
	external auto_msg_inpval
c
	logical auto_check_alfnum
c
	istat = idx			!to prevent not-used warnings
	istat = 1
	if(partial .eq. 'E') then
c
c THe expand works as follows
c  take the current value
c  if empty : take today
c  the tab key will increase the last entered field (day,month,yes,hour,min,sec,hun)
c  the f12 key will decrease the last entered field
c so if the date was
c  12-aug      the tab will display 12-sep and f12 will display 12-jul
c  12-aug-2005 the tab will display 12-aug-2006 and f12 will display 12-aug-2004
c
	  call sys$gettim(date)
	  call sys$numtim(numtim,date)
	  do k=4,7
	    numtim(k) = 0
	  enddo
c
	  if(line .eq. ' ') then
	    call lib$cvt_vectim(numtim,date)
	  else
c
c DO a convert with all fields defaulted
c Make a fixed format
c 
	    if(line(2:2) .eq. '-') then
	      datetime(1:1) = '0'
	      call str$upcase(datetime(2:),line)
	      n = len(line) + 1
	    else
	      call str$upcase(datetime,line)
	      n = len(line)
	    endif
c
c If pos 12 (separator between date and time) = ':' make it space
c
	    if(datetime(12:12) .eq.':') datetime(12:12) = ' '
	    istat = lib$convert_date_string(datetime(1:n),date,,
     1                                      127,numtim,flags)
	    if(.not. istat) goto 80
c
c See the lowest field filled in
c The order is dat,month,year,hour,minute,seco,hundr
c Flags contains the defaulted fields
c  if the bit is not set, the value is present
c
	    flag = lib$m_day
	    if(pos .ge. 4) flag = lib$m_month
	    if(pos .ge. 8) flag = lib$m_year
	    if(pos .ge. 12) flag = lib$m_hour
	    if(pos .ge. 15) flag = lib$m_minute
	    if(pos .ge. 18) flag = lib$m_second
	    if(pos .ge. 21) flag = lib$m_hundredths
c
c COmpute th index and the direction
c
	    if(flag .eq. lib$m_month) then
c
c Special case, since months do not have a fixed time
c 
	      call sys$numtim(numtim,date)
	      if(forward) then
	        numtim(2) = numtim(2) + 1
	        if(numtim(2) .gt. 12) then
	          numtim(2) = 1
	          numtim(1) = numtim(1) + 1
	        endif
	      else
	        numtim(2) = numtim(2) - 1
	        if(numtim(2) .le. 0) then
	          numtim(2) = 12
	          numtim(1) = numtim(1) - 1
	        endif
	      endif
	      call lib$cvt_vectim(numtim,date)
	    elseif(flag .eq. lib$m_year) then
c
c Special case, since years do not have a fixed time
c
	      call sys$numtim(numtim,date)
	      if(forward) then
	        numtim(1) = numtim(1) + 1
 	      else	
	        numtim(1) = numtim(1) - 1
	      endif
	      call lib$cvt_vectim(numtim,date)
	    else
	      if(flag .eq. lib$m_day) then
	        call lib$cvt_to_internal_time(lib$k_delta_days   ,1,inc_date) 
	      elseif(flag .eq. lib$m_hour) then
	        call lib$cvt_to_internal_time(lib$k_delta_hours  ,1,inc_date) 
	      elseif(flag .eq. lib$m_minute) then
	        call lib$cvt_to_internal_time(lib$k_delta_minutes,1,inc_date) 
	      elseif(flag .eq. lib$m_second) then
	        call lib$cvt_to_internal_time(lib$k_delta_seconds,1,inc_date) 
	      else
	        call lib$emul(-10*1000*10,1,0,inc_date)
	      endif
	      if(forward) then
	        call lib$add_times(date,inc_date,date)
	      else
	        call lib$sub_times(date,inc_date,date)
	      endif
	    end if
	  endif
c
c Now convert the date back to ascii
c
	  call sys$asctim(nk_value,value,date,)
	  value(12:12) = ':'
	  if(value(1:1) .eq. ' ') then
c
c  Remove leading space
c
	    value = value(2:nk_value)
	    nk_value = nk_value - 1
	  endif
c
c And signal this new value to override the old one
c
	  pos = -1
c
	elseif(partial .eq. 'P') then
	  if(auto_check_alfnum(kar) .or.
     1       index(':-.',kar) .ne. 0 .or.
     1       kar .eq. kar_delete) then
	    nk_value = len(line)
	  else
	    nk_value = -1
	    if(special_kar) goto 90
	    goto 80
	  endif
	elseif(partial .eq. 'F') then
c
c Only full checking is oke
c
	  call sys$numtim(numtim,date)
	  do k=4,7
	    numtim(k) = 0
	  enddo
	  if(line(2:2) .eq. '-') then
	    datetime(1:1) = '0'
	    call str$upcase(datetime(2:),line)
	    n = len(line) + 1
	  else
	    call str$upcase(datetime,line)
	    n = len(line)
	  endif
c
c If pos 12 (separator between date and time) = ':' make it space
c
	  if(datetime(12:12) .eq.':') datetime(12:12) = ' '
	  if(.not. lib$convert_date_string(
     1               datetime(1:n),date,,
     1               127,numtim)) goto 80
c
c Should be >=0, else deltatime
c
	  if(date(2) .lt. 0) goto 80
	  nk_value = 0		!clear upper word
	  call sys$asctim(nk_value,value,date,)
	  value(12:12) = ':'
c
	  if(value(1:1) .eq. ' ') then
c
c  Remove leading space
c
	    value = value(2:nk_value)
	    nk_value = nk_value - 1
	  endif
	elseif(partial .eq. 'L') then
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1          %descr('datetime string'))
	endif
	goto 90
80	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invdat,line)
	nk_value = -1
90	auto_check_value_datetime = istat
	return
	end
	function auto_check_value_deltatime(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                     value,nk_value,pos,forward)
	implicit none
c
c  Check function for  $deltatime
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 pos				!:io: position
	logical*4 forward			!:i: expand forward?
	integer*4 auto_check_value_deltatime
c
	include '($libdtdef)'
	integer*4 istat,date(2),inc_date(2),flag
c
	integer*4 auto_msg
	external auto_msg_invddat
	external auto_msg_inpval
c
	logical auto_check_date_fields
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = idx			!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	istat = 1
	if(partial .eq. 'E') then
c
c THe expand works as follows
c  take the current value
c  if empty : take today
c   see wheich field are filled in
c
	  if(line .eq. ' ') then
	    flag = lib$m_day
c
c Make the lowest negative date
c
	    call lib$emul(-10*1000*10,0,-1,date)
	  else
	    if(.not. auto_check_date_fields(line,pos,flag,date)) goto 80
	    if(date(2) .ge. 0) goto 89
c
	    if(flag .eq. lib$m_day) then
	      call lib$cvt_to_internal_time(lib$k_delta_days   ,1,inc_date) 
	    elseif(flag .eq. lib$m_hour) then
	      call lib$cvt_to_internal_time(lib$k_delta_hours  ,1,inc_date) 
	    elseif(flag .eq. lib$m_minute) then
	      call lib$cvt_to_internal_time(lib$k_delta_minutes,1,inc_date) 
	    elseif(flag .eq. lib$m_second) then
	      call lib$cvt_to_internal_time(lib$k_delta_seconds,1,inc_date) 
	    else
	      call lib$emul(-10*1000*10,1,0,inc_date)
	    endif
	    if(forward) then
	      call lib$add_times(date,inc_date,date)
	    else
	      call lib$sub_times(date,inc_date,date)
	    endif
	  endif
	  if(date(2) .ge. 0) goto 89
c
c Now convert the date back to ascii
c
	  nk_value = 0		!clear upper word
	  call sys$asctim(nk_value,value,date,)
	  value(5:5) = '-'
	  do while(value(1:1) .eq. ' ')
	    value = value(2:)
	    nk_value = nk_Value - 1
	  end do
	  pos = -1		!signal replace
c
	elseif(partial .eq. 'P') then
	  if(.not. auto_check_date_fields(line,pos,flag,date)) goto 89
c
c If we have an empty string, date will be 0, so do not check
c   the deltatime (date(2) <0)
c
	  nk_value = len(line)
	elseif(partial .eq. 'F') then
c
c Only full checking is oke
c
	  if(.not. auto_check_date_fields(line,pos,flag,date)) goto 80
	  if(date(2) .ge. 0) goto 80
	  nk_value = 0
	  call sys$asctim(nk_value,value,date,)
	  value(5:5) = '-'
	  do while(value(1:1) .eq. ' ')
	    value = value(2:)
	    nk_value = nk_Value - 1
	  end do
	elseif(partial .eq. 'L') then
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1          %descr('deltatime string'))
	endif
	goto 90
80	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invddat,line)
89	nk_value = -1
90	auto_check_value_deltatime = istat
	return
	end
	function auto_check_date_fields(line,pos,flag,date)
	implicit none
c
	include '($libdtdef)'
c
	character*(*) line      !:i: the (partial) date
	integer*4 pos		!:i: the pos of the cursor in the string
	integer*4 flag		!:o: the field where the cursor is
	integer*4 date(2)       !:o: the date
	logical*4 auto_check_date_fields !:f: true is valid date
c
	integer*4 nday,nhour,nminute,nsecond,nhundred
	integer*4 ipos,jpos,nk
	character*16 datasc
c
	integer*4 str$find_first_in_set
c
	nday     = 0
	nhour    = 0
	nminute  = 0
	nsecond  = 0
	nhundred = 0
c
c Check days field
c	
	auto_check_date_fields = .false.
c
c First try date field, if must be terminated by a space or a -
c
	ipos = str$find_first_in_set(line,' -')
c
c Read the days
c
	if(ipos .ge. 1) then
	  read(line(1:ipos-1),2000,err=90) nday
2000	  format(i4)
	  if(nday .lt. 0 .or. nday .gt. 9999) goto 90
	  if(pos .lt. ipos) flag = lib$m_day
	endif	
c
c Signal day used (always)
c
c
	if(ipos .lt. len(line)) then
c
c Get hour field
c
	  jpos = index(line(ipos+1:),':')
	  if(jpos .eq. 0) then
	    jpos = len(line)+1
	  else
	    jpos = jpos + ipos
	  endif
	  read(line(ipos+1:jpos-1),2000,err=90) nhour
	  if(nhour .lt. 0 .or. nhour .gt. 23) goto 90
	  if(pos .ge. ipos .and. pos .lt. jpos) flag = lib$m_hour
	  ipos = jpos 
c
	  if(ipos .lt. len(line) ) then
c
c Get minute field
c
	    jpos = index(line(ipos+1:),':')
	    if(jpos .eq. 0) then
	      jpos = len(line)+1
	    else
	      jpos = jpos + ipos
	    endif
	    read(line(ipos+1:jpos-1),2000,err=90) nminute
	    if(nminute .lt. 0 .or. nminute .gt. 59) goto 90
	    if(pos .ge. ipos .and. pos .lt. jpos) flag = lib$m_minute
	    ipos = jpos 
c
	    if(ipos .lt. len(line) ) then
c
c Get second field
c
	      jpos = index(line(ipos+1:),'.')
	      if(jpos .eq. 0) then
	        jpos = len(line)+1
	      else
	        jpos = jpos + ipos
	      endif
	      read(line(ipos+1:jpos-1),2000,err=90) nsecond
	      if(nsecond .lt. 0 .or. nsecond .gt. 59) goto 90
	      if(pos .ge. ipos .and. pos .lt. jpos) flag = lib$m_second
	      ipos = jpos 
c
	      if(ipos .lt. len(line) ) then
c
c Get hundredth
c
	        read(line(ipos+1:),2000) nhundred
	        if(nhundred .lt. 0 .or. nhundred .gt. 99) goto 90
	        if(pos .gt. ipos) flag = lib$m_hundredths
	      endif
	    endif
	  endif
	endif
c
	call sys$fao('!4ZL !2ZL:!2ZL:!2ZL.!2ZL',nk,datasc,
     1       %val(nday),%val(nhour),%val(nminute),
     1       %val(nsecond),%val(nhundred))
	call sys$bintim(datasc(1:nk),date)
	if(date(1) .eq. 0 .and. date(2) .eq. 0) then
c
c Catch the all zero case, make is small negative
c
	  call lib$emul(-10*1000*10,0,-1,date)
	endif
	auto_check_date_fields = .true.
c
90	return
	end
c
	function auto_check_value_protection(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for $protection
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_protection
c
	integer*4 istat,bpos,nk1,mask1,mask2
c
	integer*4 auto_msg
	integer*4 lib$parse_sogw_prot
	external auto_msg_inpval
	external auto_msg_invprot
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = idx			!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	istat =1
	if(partial .eq. 'E') then
c
c We have no expand on protection return -1
c
	  nk_value = -1
c
	elseif(partial .eq. 'P') then
c
c Valid chars are
c  /prot=(wo:rwe,...)
c so the ( can be only at the first pos
c
	  nk_value = -1
	  bpos = 1
	  nk1 = len(line)
	  if(line(1:1) .eq. '(') then
	    bpos = 2
	    if(line(nk1:nk1) .eq. ')') nk1 = nk1 - 1
	  endif
	  if(.not. lib$parse_sogw_prot(line(bpos:nk1),,
     1               mask1,mask2)) goto 80
	  nk_value = len(line)
	  goto 90
	elseif(partial .eq. 'F') then
	  nk_value = -1
	  nk1 = len(line)
	  bpos = 1
	  if(line(1:1) .eq. '(') then
	    bpos = 2
	    if(line(nk1:nk1) .ne. ')') goto 90
	    nk1 = nk1-1
	  endif
	  if(.not. lib$parse_sogw_prot(line(bpos:nk1),,
     1               mask1,mask2)) goto 80
	  nk_value = len(line)
	  value = line
	elseif(partial .eq. 'L') then
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1          %descr('protection string'))
	endif
	goto 90
80	istat = auto_msg(auto_info.ptr_terminal_info,
     1                   auto_msg_invprot,line)
90	auto_check_value_protection= istat
	return
	end
c
	function auto_check_value_process(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for processname
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_process
c
	integer*4 istat,kstat,iosb(2),nf,pid
c
	include '($jpidef)'
c
	integer*4 sys$getjpiw
	integer*4 auto_help_add
	integer*4 auto_help_display
c
	integer*4 auto_msg
	external auto_msg_invprc
	external auto_msg_ambigprc
	external auto_msg_quotes
c
	structure /item/ 
	  integer*2 buflen,opcode
	  integer*4 bufadr,retadr
	end structure
c
	record /item/ items(2)
	character*30 prcnam,prcwork
	integer*4 nk_prcnam,nk_w
	logical in_quote
	logical auto_check_unquote
c
	volatile prcnam,nk_prcnam
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	istat = 1
c
	items(1).opcode = jpi$_prcnam
	items(1).buflen = len(prcnam)
	items(1).bufadr = %loc(prcnam)
	items(1).retadr = %loc(nk_prcnam)
c
c Make a search field
c
	in_quote = .not. auto_check_unquote(line,prcwork,nk_w)
	if(nk_w .gt. 15) goto 80
c
	pid = -1
	if(partial .eq. 'E') then
c
c Make a list of processnames
c
	  if(idx .ge. 0) then
	    nf = 0
10	    kstat = sys$getjpiw(,pid,,items,iosb,,)
	    if(kstat) kstat = iosb(1)
	    if(kstat) then
	      if(nk_w .gt. nk_prcnam) goto 10
	      if(prcwork(1:nk_w) .ne. prcnam(1:nk_w)) goto 10
	      nf = nf + 1
	      if(nf .ne. idx) goto 10
c
	      value = prcnam(1:nk_prcnam)
	      nk_value = nk_prcnam	 
	      goto 90
	    endif	    
	  endif
	  goto 80
	elseif(partial .eq. 'F' .or. partial .eq. 'P') then
c
c Make a list of processnames
c
	  nf = 0
	  if(partial .eq. 'F' .and. in_quote) goto 70
c
20	  kstat = sys$getjpiw(,pid,,items,iosb,,)
	  if(kstat) kstat = iosb(1)
	  if(kstat) then
	    if(nk_w .le. nk_prcnam)then
	      if(prcwork(1:nk_w) .eq. prcnam(1:nk_w)) nf = nf + 1
	    end if
	    goto 20
	  endif	    
c
c Nf contains # matches
c  nf=0 : error
c  nf=1 : all oke
c  nf>1 : Error for full match , that one must be unique
c
	  if(nf .eq. 0) goto 80	  
	  if(partial .eq. 'F') then
	    if(nf .gt. 1) goto 85
	  endif
	  nk_value = len(line)
c
c For F check and all oke : return value
c
	  if(partial .eq. 'F') value = line
	elseif(partial .eq. 'L') then
c
c Make a list of processnames
c
	  nf = 0
30	  kstat = sys$getjpiw(,pid,,items,iosb,,)
	  if(kstat) kstat = iosb(1)
	  if(kstat) then
	    if(nk_w .gt. nk_prcnam) goto 30
	    if(prcwork(1:nk_w) .ne. prcnam(1:nk_w)) goto 30
	    if(.not. auto_help_add(auto_info.ptr_terminal_info,
     1              prcnam(1:nk_prcnam))) goto 34
	    goto 30
	  endif	    
34	  istat = auto_help_display(auto_info.ptr_terminal_info,
     1                             'Processname')
	endif
	goto 90	  
70	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_quotes,line)
	nk_value = -1
	goto 90
80	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invprc,line)
	nk_value = -1
	goto 90
85	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_ambigprc,line)
	nk_value = -1
	goto 90
c
90	auto_check_value_process = istat
	return
	end
c
	function auto_check_value_inlog(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for logical
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_inlog
c
	integer*4 istat,k,nk
	integer*4 nkar
	logical*4 exact,wild
	character*(max_line_length) result
	character*255 work
c
	integer*4 auto_msg
	integer*4 str$find_first_in_set
	external auto_msg_invlog
	external auto_msg_ambigl
	integer*4 symbols_match
	integer*4 auto_help_add
	integer*4 auto_help_display
	integer*4 auto_check_value_outlog
c
	if(.not. auto_info.do_logicals) then
c
c No logical read in, o only check for validity
c
	  istat = auto_check_value_outlog(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	  goto 90
	endif
	istat = 1
	if(partial .eq. 'P' .or. partial .eq. 'F') then
	  nk = len(line)
	  wild = str$find_first_in_set(line,'*%') .ne. 0
	  call str$upcase(work(1:nk),line)
	  call symbols_rewind(auto_info.ptr_symbol_info,
     1                        auto_info.ptr_terminal_info)
	  k = 0
	  do while(symbols_match(auto_info.ptr_symbol_info,
     1                           work(1:nk),
     1                           result,nkar,exact,2,
     1                        auto_info.ptr_terminal_info,wild))
	    k = k + 1
	  end do
c
	  nk_value = len(line)
	  if(k .gt. 1 .and. .not. wild) then
	    if(partial .eq. 'F') then
	      istat = auto_msg(auto_info.ptr_terminal_info,
     1                         auto_msg_ambigl,line)
	      nk_value = -1
	    endif
	  elseif(k .eq. 0) then
c
c No match at all
c
	    istat = auto_msg(auto_info.ptr_terminal_info,
     1                       auto_msg_invlog,line)
	    nk_value = -1
	  endif
c
c For F check and all oke : return value
c
	  if(partial .eq. 'F' .and. nk_value .gt.0) value = line
	elseif(partial .eq. 'L') then
	  nk = len(line)
	  wild = str$find_first_in_set(line,'*%') .ne. 0
	  call symbols_rewind(auto_info.ptr_symbol_info,
     1                        auto_info.ptr_terminal_info)
	  do while(symbols_match(auto_info.ptr_symbol_info,
     1                           work(1:nk),
     1                           result,nkar,exact,2,
     1                        auto_info.ptr_terminal_info,wild))
	    if(.not. auto_help_add(auto_info.ptr_terminal_info,
     1              result(1:nkar))) goto 34
	  end do
34	  istat = auto_help_display(auto_info.ptr_terminal_info,'Logical')
	elseif(partial .eq. 'E') then
c
	  if(idx .ge. 0) then
	    call symbols_rewind(auto_info.ptr_symbol_info,
     1                        auto_info.ptr_terminal_info)
	    k = 0
	    nk = len(line)
	    wild = str$find_first_in_set(line,'*%') .ne. 0
	    do while(symbols_match(auto_info.ptr_symbol_info,
     1                           work(1:nk),
     1                           value,nk_value,exact,2,
     1                        auto_info.ptr_terminal_info,wild))
	      k = k + 1
	      if(k .eq. idx) goto 90
	    end do
	  endif
c
c So sorry, not valid
c 
	  nk_value = -1
	endif
	goto 90
80	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invlog,line)
	nk_value = -1
90	auto_check_value_inlog = istat
	return
	end
	function auto_check_value_outlog(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for $outlog, logicalname for output
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character*(*) partial			!:i: the mode to check P/E/F
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_outlog
c
	integer*4 istat,k
	integer*4 dummy
	character*1 test
c
	integer*4 auto_msg
	external auto_msg_invlog
	external auto_msg_inpval
c
	logical*4 auto_check_normal
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	istat = 1
	dummy = idx
	dummy = nk_value
	test  = value(1:1)
c
	if(partial .eq. 'P' .or. partial .eq. 'F') then
	  if(len(line) .gt. 255) goto 80
	  do k=1,len(line)
	    if(.not. auto_check_normal(line(k:k))) goto 80
	  end do
	  nk_value = len(line)
c
c For F check and all oke : return value
c
	  if(partial .eq. 'F' .and. nk_value .gt.0) value = line
	elseif(partial .eq. 'E') then
c
c We have no expand on outsym, return -1
c
	  nk_value = -1
c
	elseif(partial .eq. 'L') then
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1                %descr('logical name'))
	endif
	goto 90
80	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invlog,line)
	nk_value = -1
90	auto_check_value_outlog = istat
	return
	end
c
c
	function auto_check_value_insym(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for $insym *symbolname for input)
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_insym
c
	integer*4 istat,k,nkar,nk
	logical*4 exact,wild
c
	character*255 work
	character*4095 result
c
	integer*4 auto_help_add
	integer*4 auto_help_display
	integer*4 str$find_first_in_set
	integer*4 auto_check_value_outsym
	logical symbols_match
	integer*4 auto_msg
c
	external auto_msg_ambigs
	external auto_msg_invsym
	external auto_msg_symnotf
	external auto_msg_inpval
c
	if(.not. auto_info.do_symbols) then
c
c No symbols read in, so only check for validity
c
	  istat = auto_check_value_outsym(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	  goto 90
	endif
c
	if(partial .eq. 'P' .or. partial .eq. 'F') then
c
	  nk = len(line)
	  call str$upcase(work(1:nk),line)
	  wild = str$find_first_in_set(line,'*%')

	  call symbols_rewind(auto_info.ptr_symbol_info,
     1                        auto_info.ptr_terminal_info)
	  k = 0
	  do while(symbols_match(auto_info.ptr_symbol_info,
     1                           work(1:nk),
     1                           result,nkar,exact,0,
     1                        auto_info.ptr_terminal_info,wild))
	    k = k + 1
	  end do
c
	  nk_value = len(line)
	  if(k .gt. 1 .and. .not. wild) then
	    if(partial .eq. 'F') then
	      istat = auto_msg(auto_info.ptr_terminal_info,
     1                         auto_msg_ambigs,line)
	      nk_value = -1
	    endif
	  elseif(k .eq. 0) then
c
c No match at all
c
	    istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invsym,line)
	    nk_value = -1
	  endif
c
c For F check and all oke : return value
c
	  if(partial .eq. 'F' .and. nk_value .gt.0) value = line
c
	elseif(partial .eq. 'L') then
	  nk = len(line)
	  call str$upcase(work(1:nk),line)
	  wild = str$find_first_in_set(line,'*%')
	  call symbols_rewind(auto_info.ptr_symbol_info,
     1                        auto_info.ptr_terminal_info)
	  do while(symbols_match(auto_info.ptr_symbol_info,
     1                           work(1:nk),
     1                           result,nkar,exact,2,
     1                        auto_info.ptr_terminal_info,wild))
	    if(.not. auto_help_add(auto_info.ptr_terminal_info,
     1              result(1:nkar))) goto 34
	  end do
34	  istat = auto_help_display(auto_info.ptr_terminal_info,'Symbol')
	elseif(partial .eq. 'E') then
c
	  if(idx .ge. 0) then
	    call symbols_rewind(auto_info.ptr_symbol_info,
     1                        auto_info.ptr_terminal_info)
	    k = 0
	    nk = len(line)
	    call str$upcase(work(1:nk),line)
	    wild = str$find_first_in_set(line,'*%')
	    do while(symbols_match(auto_info.ptr_symbol_info,
     1                           work(1:nk),
     1                           value,nk_value,exact,0,
     1                        auto_info.ptr_terminal_info,wild))
	      k = k + 1
	      if(k .eq. idx) goto 90
	    end do
	  endif
c
c So sorry, not valid
c 
	  nk_value = -1
	endif
	goto 90
80	istat = auto_msg(auto_info,auto_msg_invsym,line)
	nk_value = -1
c
90	auto_check_value_insym = istat
	return
	end
c
	function auto_check_value_outsym(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for $outsym, symbolname for output
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character*(*) partial			!:i: the mode to check P/E/F
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_outsym
c
	integer*4 istat,k
c
	integer*4 auto_msg
	external auto_msg_invsym
	external auto_msg_inpval
c
	logical auto_check_normal
c
	istat = idx			!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	istat = 1
c
	if(partial .eq. 'P') then
	  if(len(line) .gt. 255) goto 80
	  if(.not.auto_check_normal(kar) .and. 
     1        kar .ne. kar_delete) goto 80
	  nk_value = len(line)
	elseif(partial .eq. 'F') then
	  if(len(line) .gt. 255) goto 80
	  do k=1,len(line)
	    if(.not.auto_check_normal(line(k:k))) goto 80
	  end do
	  nk_value = len(line)
	  value    = line
	elseif(partial .eq. 'E') then
c
c We have no expand on outsym, return -1
c
	  nk_value = -1
c
	elseif(partial .eq. 'L') then
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1                %descr('symbol name'))
	endif
	goto 90
80	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invsym,line)
	nk_value = -1
90	auto_check_value_outsym = istat
	return
	end
c
	function auto_check_value_node(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for user type (string)
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_node
c
	integer*4 istat,k
	integer*4 auto_msg
c
	external auto_msg_inpval
	logical auto_check_alfnum
c
	istat = idx			!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	istat = 1
	if(partial .eq. 'E') then
c
c We have no expand on node, return the input string
c
	  nk_value = -1
c
	elseif(partial .eq. 'P') then
	  nk_value = len(line)
	  if(auto_check_alfnum(kar) .or. kar .eq. kar_delete) goto 90
	  nk_value = -1
	elseif(partial .eq. 'F' .or. partial .eq. 'P') then
	  nk_value = -1
	  do k=1,len(line)
	    if(.not. auto_check_alfnum(line(k:k))) goto 90
	  end do
	  value = line
	  nk_value = len(line)
	elseif(partial .eq. 'L') then
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1                %descr('node name'))
	endif
90	auto_check_value_node = istat
	return
	end
c
	function auto_check_value_device(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for user type (string)
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_device
c
	include '($dvidef)'
	integer*4 istat,count,nk
	integer*4 ctx(2)
	character*64 devnam
c
	integer*4 lib$getdvi
	integer*4 sys$device_Scan
	integer*4 auto_msg
	logical auto_check_normal
c
	external auto_msg_invdev
	external auto_msg_inpval
c
c
	istat = special_kar		!to prevent not-used warnings
	istat = 1
	if(partial .eq. 'E') then
c
c Try to find the device
c
	  if(idx .ge. 0) then
	    devnam = '*'//line//'*'
	    nk = len(line)+2
	    call str$upcase(devnam(1:nk),devnam(1:nk))
	    count = idx
	    ctx(1) = 0
	    ctx(2) = 0
	    nk_value = 0
c
	    do while(sys$device_scan(value,nk_value,devnam(1:nk),,ctx))
	      count = count - 1
	      if(count .eq. 0) goto 90
	    enddo
	  endif
	  nk_value = -1
	elseif(partial .eq. 'F') then
c
c Full check
c
	  nk_value = 0	!clear upper word
	  if(.not. lib$getdvi(dvi$_devnam,,line,,value,nk_value)) then
	    istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invdev,line)
	    nk_value = -1
	  endif
	elseif(partial .eq. 'P') then
	  if(auto_check_normal(kar) .or. 
     1       kar .eq. kar_delete) then
	    nk_value = len(line)
	  else
	    nk_value = -1
	  endif
	elseif(partial .eq. 'L') then
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1            %Descr('(existing) device name'))
	endif	
90	auto_check_value_device = istat
	return
	end
c
	function auto_check_value_directory(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for directory
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_directory
c
	integer*4 istat,nk,nbr,last_dot,first_br
c
	integer*4 auto_help_display
	integer*4 auto_msg
	external auto_msg_inpval
	logical*4 auto_check_filename
	logical*4 auto_check_dir_parse
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = 1
	nk = len(line)
c
	if(partial .eq. 'E') then
c
c Expand , try to locate the (deeper) (sub) directories 
c
	  nk_value = -1
	  nbr = 0
	  last_dot = 0
	  if(idx .ge. 0) then
	    if(.not. auto_check_dir_parse(line,nbr,last_dot,first_br)) then
	      goto 90
	    endif
c
c Now if level=0, the last character must be a ]
c
	    if(nbr .eq. 0) then
	      if (line(nk:nk) .ne. ']') goto 90
	    elseif(nbr .gt. 0) then
c
c We are in de deeper directory, list all directories
c
	      call auto_check_dir_expand(line,value,idx,last_dot,
     1                                   first_br,nk_value)
	    endif
	  endif	
c
	elseif(partial .eq. 'L') then
c
	  nk_value = -1
	  if(.not. auto_check_dir_parse(line,nbr,last_dot,first_br)) then
	    goto 90
	  endif
          if(nbr .gt. 0) then
	    call auto_check_dir_help(line,last_dot,first_br,
     1                               auto_info.ptr_terminal_info)
	    istat = auto_help_display(auto_info.ptr_terminal_info,'Directorie')
	  else
	    istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1            %descr('directory name')) 
	  endif
	elseif(partial .eq. 'P' .or. partial .eq. 'F') then
	  if(special_kar) then
	    nk_value = -1
	  else
	    if(auto_check_filename(line,partial .eq. 'P',
     1                                  partial .eq. 'F')) then
	      nk_value = len(line)
	    else
	      nk_value = -1
	    endif
	  endif
c
c For F check and all oke : return value
c
	  if(partial .eq. 'F' .and. nk_value .gt.0) value = line
	endif
90	istat = 1
	auto_check_value_directory = istat
	return
	end
c
	function auto_check_value_uic(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for UIC
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_uic
c
c
	integer*4 istat,nk,ipos,k
	integer*4 auto_msg
	external auto_msg_inpval
	external auto_msg_invuic
c
	logical*4 auto_check_normal
c
	istat = idx			!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	istat = 1
c
	nk = len(line)
c
	if(partial .eq. 'E') then
c
c We have no expand on uic, return -1
c
	  nk_value = -1
c
	elseif(partial .eq. 'L') then
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1            %descr('UIC ([group,number])')) 
	elseif(partial .eq. 'P') then
c 
c #need some
c
	  if(auto_check_normal(kar) .or.
     1       index('[,]',kar) .ne. 0 .or.
     1       kar .eq. kar_delete) then
	    nk_value = len(line)
	  else
	    nk_value = -1
	  endif
	elseif(partial .eq. 'F') then
	  nk_value = -1
	  istat = 1
	  if(line(1:1) .ne. '[' .or. line(nk:nk) .ne. ']') goto 80
	  ipos = index(line,',')
c
c See if numbers
c
	  if(ipos .eq. 0) goto 20
	  read(line(2:ipos-1),2000,err=20) k
	  if(k .lt. 0 .or. k .gt. 16383) goto 80
2000	  format(o10)
	  read(line(ipos+1:nk-1),2000,err=80) k
	  if(k .lt. 0 .or. k .gt. 32767) goto 80
c
c Now not numbers, all oke, can be ascii
c
20	  nk_value = len(line)
	  value    = line
	endif
	goto 90
80	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invuic,line)
	nk_value = -1
90	auto_check_value_uic = istat
	return
	end
c
	function auto_check_value_restofline(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for restofline
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_restofline
c
	integer*4 istat
	integer*4 auto_msg
	external auto_msg_inpval
c
c We have no check for restofline, return the input string
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = idx			!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	nk_value = len(line)
c
	if(partial .eq. 'L') then
c
c Only the help is processed
c
	  istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1            %Descr('restofline value'))
	elseif(partial .eq. 'E') then
	  nk_value = -1
	elseif(partial .eq. 'P') then
c
c  All oke
c
	elseif(partial .eq. 'F') then
c
c  All oke
c  	 
	  value = line
	endif
	istat = 1
	auto_check_value_restofline = istat
	return
	end
c
	function auto_check_value_parenvalue(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for user type (string)
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_parenvalue
c
	integer*4 istat,k,brlev
	logical in_string
	integer*4 auto_msg
c
	external auto_msg_inpval
	external auto_msg_openbr
	external auto_msg_closbr
	external auto_msg_unbal
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	istat = 1
	if(partial .eq. 'E') then
c
c Auto expand all closing ) if not there
c
	  if(idx .lt. 0) goto 89
	  brlev = 0
	  in_String = .false.
c
	  nk_value = 0
	  do k=1,len(value)
	    if(line(k:k) .eq. '"') in_String = .not. in_string
	    if(.not. in_string) then
	      if(line(k:k) .eq. '(') brlev = brlev + 1
	      if(line(k:k) .eq. ')') brlev = brlev - 1
	      if(brlev .lt. 0) goto 88
	    endif
	  end do
	  nk_value = len(line)
	  do k=1,brlev
	    nk_value = nk_value + 1
	    value(nk_value:nk_value) = ')'
	  enddo
	elseif(partial .eq. 'P') then
c
c PArtial, check for the open bracket
c
	  if(line(1:1) .ne. '(') goto 80
	  brlev = 0
	  do k=1,len(value)
	    if(line(k:k) .eq. '"') in_String = .not. in_string
	    if(.not. in_string) then
	      if(line(k:k) .eq. '(') brlev = brlev + 1
	      if(line(k:k) .eq. ')') brlev = brlev - 1
	      if(brlev .lt. 0) goto 88
	    endif
	  end do
	  nk_value = len(line)
	elseif(partial .eq. 'F') then
c
c Full , check for the open and close bracket
c
	  brlev = 0
	  in_String = .false.
	  if(line(1:1) .ne. '(') goto 80
	  if(line(nk_value:nk_value) .ne. ')') goto 85
c
	  do k=1,len(value)
	    if(line(k:k) .eq. '"') in_String = .not. in_string
	    if(.not. in_string) then
	      if(line(k:k) .eq. '(') brlev = brlev + 1
	      if(line(k:k) .eq. ')') brlev = brlev - 1
	      if(brlev .lt. 0) goto 88
	    endif
	  end do
	  if(brlev .ne. 0) goto 88
	  nk_value = len(line)
	  value = line
c
	elseif(partial .eq. 'L') then
	  istat= auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1          %descr('Parentherised value'))
	endif
	goto 90
c
80	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_openbr,line)
	nk_value = -1
	goto 90
85	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_closbr,line)
	nk_value = -1
	goto 90
88	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_unbal,line)
89	nk_value = -1
	goto 90
90	auto_check_value_parenvalue = istat
	return
	end
c
c
	function auto_check_value_quotedstr(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for user type (string)
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_quotedstr
c
	integer*4 auto_check_value_string 
	integer*4 istat                 
c
c We have no expand on quoted string, return the same as user_type (string)
c
	istat = auto_check_value_string(auto_info,
     1                    line,kar,special_kar,
     1                    partial(1:1),idx,value,nk_value)
	auto_check_value_quotedstr = istat
	return
	end
c
	function auto_check_value_file(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for file
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_file
c
	integer*4 istat
	integer*4 auto_check_value_outfile
c
	istat = auto_check_value_outfile(auto_info.ptr_terminal_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value,' ')
	auto_check_value_file = istat   
	return
	end
c
	function auto_check_value_expression(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                    value,nk_value)
	implicit none
c
c  Check function for user type (string)
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_expression
c
	integer*4 istat
	integer*4 auto_msg
	external auto_msg_inpval
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = idx			!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	istat = 1
	if(partial .eq. 'E') then
c
c We have no expand on expression, return -1
c
	  nk_value = -1
c
	elseif(partial .eq. 'F') then
	  value = line
	  nk_value = len(line)
	elseif(partial .eq. 'P') then
	  nk_value = len(line)
	elseif(partial .eq. 'L') then
	  istat= auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1          %descr('expression'))
	endif
	auto_check_value_expression = istat
	return
	end
	function auto_check_value_acl(auto_info,
     1                    line,kar,special_kar,partial,idx,
     1                     value,nk_value)
	implicit none
c
c  Check function for user type (string)
c
	include 'auto.inc'
	record /auto_info/ auto_info	!:i: terminal block
	character*(*) line			!:i: the string to check
	character kar				!:i: the char to be inserted
	logical*4 special_kar			!:i: special kar?
	character*(*) partial			!:i: the mode to check P/E/F
	integer*4 idx				!:i: the so many'th
	character*(*) value			!:o: the value found
	integer*4 nk_value			!:o: the length
	integer*4 auto_check_value_acl
c
	byte data(512)
	integer*4 istat,brlev,k
	integer*4 sys$parse_acl
	integer*4 auto_msg
	external auto_msg_invacl
	external auto_msg_inpval
c
	istat = ichar(kar)		!to prevent not-used warnings
	istat = idx			!to prevent not-used warnings
	istat = special_kar		!to prevent not-used warnings
	istat = 1
	if(partial .eq. 'E') then
c
c We have no expand on acl return -1
c
	  nk_value = -1
c
	elseif(partial .eq. 'P') then
	  nk_value = -1
	  if(line(1:1) .ne. '(') goto 90
	  brlev = 0
	  do k=1,len(line)
	    if(line(k:k) .eq. '(') brlev = brlev + 1
	    if(line(k:k) .eq. ')') brlev = brlev - 1
	    if(brlev .lt. 0) goto 80
	  enddo
	  nk_value = len(line)
c
	elseif(partial .eq. 'F') then
	  if(line(1:1) .ne. '(') goto 80
	  if(line(len(line):len(line)) .ne. ')') goto 80
c
	  if(.not. sys$parse_acl(line,data)) goto 80
	  nk_value = len(line)
	  value = line
c
	elseif(partial .eq. 'L') then
	  istat= auto_msg(auto_info.ptr_terminal_info,auto_msg_inpval,
     1          %descr('ACL string'))
	endif
	goto 90
80	istat = auto_msg(auto_info.ptr_terminal_info,auto_msg_invacl,line)
90	auto_check_value_acl = istat
	return
	end
	function auto_check_dir_parse(line,nbr,last_dot,first_bracket)
	implicit none
c
	character*(*) line   		!:i: the filename
	integer*4 nbr                   !:o: open bracket count
	integer*4 last_dot              !:o: position of last . (or 0)
	integer*4 first_bracket         !:o: position of first [ (or 0).
	logical*4 auto_check_dir_parse	!:f: false in nbr<0 or >1.
c
	integer*4 k
c
	nbr = 0
	last_dot = 0
	first_bracket = 0
c
	auto_check_dir_parse = .false.
c
	do k=1,len(line)
	  if(k .eq. 1 .or. line(k-1:k-1) .ne. '^') then
	    if(line(k:k) .eq. '[') then
	      if(first_bracket .eq. 0) first_bracket = k
	      nbr = nbr + 1
	    endif
	    if(line(k:k) .eq. ']') nbr = nbr - 1
	    if(line(k:k) .eq. '.') last_dot = k
	    if(nbr .lt. 0 .or. nbr .gt. 1) goto 90
	  end if
	end do
	auto_check_dir_parse = .true.
90	return
	end	  

