	function dix_inter_recall(control,keyb_id,line,nkar)
	implicit none
c
c Check if the verb contains recall ?? 
c  and act upon it
c
	include 'dix_def.inc'
	record /control/ control!:i: control block
	integer*4 keyb_id	!:i: keyboard it
	character*(*) line	!:io: line (will be updated if recall)
	integer*4 nkar		!:io: length of line, will be updated if recall
	logical*4 dix_inter_recall !:f: False if no valid line
c
	include '($smgdef)'
	record /smg$r_attribute_info_block/ p_kit
c
	character*10 verb
	character*(max_command_length) line_in,line_upper
	integer*4 nk_verb,n_recall,k,nf,nk_mask,nkar_inp,istat
	logical*4 search_it
c
	integer*4 str$find_first_in_set
	integer*4 str$find_first_not_in_set
	integer*4 smg$return_input_line
	integer*4 str$case_blind_compare
c
	external dix_msg_recasyn
	external dix_msg_cmdnotfnd
	external dix_msg_norecall

c
	logical*4 dix_util_match
c
c
c Assume no recall line
c
	dix_inter_recall = .true.
c
	nk_verb = str$find_first_in_set(line(1:nkar),' /')-1
	if(nk_verb .lt. 0) nk_verb = nkar
	call str$upcase(verb,line(1:nk_verb))
	if(dix_util_match(verb(1:nk_verb),'RECA|LL')) then
	  dix_inter_recall = .false.
c
c Get the recall count
c
          call smg$get_keyboard_attributes(keyb_id,p_kit,
     1                    smg$c_keyboard_info_block)
c
          n_recall = zext(p_kit.smg$b_recall_num)
c
	  if(n_recall .gt. 0) then
c
c Skip recall line from recall buffer
c
	    call smg$replace_input_line(keyb_id)
	    k = index(line,'/')
c
c Qualifier specified, so check for /erase, of /all, !/Input, /output
c
	    if(k .ne. 0) then
	      call str$upcase(verb,line(k+1:))
	      nk_verb = str$find_first_in_set(verb,' /=')-1
	      if(dix_util_match(verb(1:nk_verb),'E|RASE')) then
c
c Recall/erase, skip all recall lines
c
	        call smg$replace_input_line(keyb_id,,n_recall)
	      elseif(dix_util_match(verb(1:nk_verb),'A|LL') .or.
     1               dix_util_match(verb(1:nk_verb),'S|EARCH')) then
c
c Recall/all or /search
c
	        nf = 0
	        search_it = verb(1:1) .eq. 'S'
	        do while(line(k:k) .ne. ' ')
	          k = k + 1
	        end do
	        if(line(k:) .eq. ' ') then
	          nk_mask = 0
	        else
	          do while(line(k:k) .eq. ' ')
	            k = k + 1
	          end do
	          call str$upcase(line,line(k:))
	          nk_mask = index(line,' ')-1
	        end if
	        do k=1,n_recall
	          if(smg$return_input_line(keyb_id,line_in,,k,nkar_inp))then
	            if(nkar_inp .gt. 0) then
	              if(nk_mask .gt. 0) then
	                if(search_it .and. nk_mask .gt. 0) then
	                   call str$upcase(line_upper,line_in(1:nkar_inp))
	                   if(index(line_upper(1:nkar_inp),line(1:nk_mask))
     1                        .eq. 0) goto 141
	                else
	                  if(str$case_blind_compare(line(1:nk_mask),
     1                     line_in(1:nk_mask)) .ne. 0) goto 141
	                endif
	              end if
	              nf = nf + 1
	              write(*,1087) k,line_in(1:nkar_inp)
1087	              format(1x,i3,1x,a)
	            end if
	          end if
141	        end do	        
	        if(nf .eq. 0) call dix_message(control,dix_msg_cmdnotfnd)
	        dix_inter_recall = .false.
	      else
	        call dix_message(control,dix_msg_recasyn)
	      endif	      
	      nkar = 0
	    else
c
c No qualifier, now the text must contain
c  either a number, or a text to match
c
	      k = index(line(1:nkar),' ')	!look for space, so skip RECA
	      line = line(k:)		!and ignore that
	      nkar = nkar - k+1
	      if(line .ne. ' ') then	!find first non blank
	        k = str$find_first_not_in_set(line,' ')
	        line = line(k:)
	        nkar = nkar - k + 1
	      else			!make line 1 to recall most recent
	        line = '1'
	        nkar = 1
	      end if
	      call str$upcase(line_in,line(1:nkar))
c
c Real recall value, try number first
c
	      nkar_inp = 0
	      read(line_in(1:nkar),'(bn,i4)',err=88) k
	      if(k .lt. 1 .or. k .gt. n_recall) goto 88
	      istat = smg$return_input_line(keyb_id,line,,k,nkar_inp)
	      if(.not. istat) nkar_inp = 0
88	      if(nkar_inp .eq. 0) then	      
	        istat = smg$return_input_line(keyb_id,line,
     1                     line_in(1:nkar),,nkar_inp)
	        if(.not. istat) nkar_inp = 0
	      end if
	      if(nkar_inp .eq. 0) then	      
	        call dix_message(control,dix_msg_norecall,line_in(1:nkar))
	        nkar = 0
	      else
	        nkar = nkar_inp
	        goto 90
	      end if		!illegal search string
	    end if		!get search string and no qualifier
	  endif			!recall input device
	  line = ' '
	  nkar = 0
	endif
90	return
	end
