	subroutine doedit(irec)
	integer*2 len
	character*255 string
	character*6 prompt
	character*4 ctrstr
	data ctrstr /'!SL>'/

	external lib$_syntaxerr
	integer editscan,sys$fao

	byte buffer(32768),edit_buffer(32768)

	common /buf/ buffer,edit_buffer,length_total

	include 'flags.inc'

	logical quit,exit,confirm,edited,abort

	common /eflags/ quit,exit,confirm,edited,abort

	prompt=' '
	istat=sys$fao(ctrstr,len,prompt,%val(irec))
	if (.not. istat) call lib$stop(%val(istat))	

 10	if (.not. readin) then
		call lib$get_input(string,prompt(1:len),length)
	 else
		read(2,15,end=9000) length,string
 15		format(q,a)
		if (echo_on) type 17,string
 17		format(' Read in:  ',a<length>)
	 end if
	if (length.eq.0) goto 10
!
! upcase string until finding a "
!
	call up_string(%ref(string),length)
	if (length.eq.0) goto 10
	istat=editscan(string(1:length),ierror)
	if (istat.eq.%loc(lib$_syntaxerr)) then
		type 20,string(1:length)
 20		format(' EDIT Error with command line:',/,x,a,/,
     1			<length-ierror+1>x,'^')

		goto 10
	 endif
	if (logging) then
		if (.not. log_open) then
			open(unit=22,name='FDMP.LOG',
     1				type='new',err=9900,recl=255,
     2				carriagecontrol='list')
			log_open=.true.
		 endif
		write(22,23) string(1:length)
 23		format(a)
	 endif
	if (quit .or. abort) return
	if (exit) call keep_record(irec,edit_buffer,length_total)
	goto 10
 9000	readin=.false.
	close(unit=2)
	goto 10
 9900	type 9110
 9110	format(/' Error in opening log file '/)
	logging=.false.
	goto 10
	end

	subroutine up_string(array,length)
	byte array(length),quote,small_a,big_a,small_z
	data quote /34/
 	data small_a /97/
	data big_a /65/
	data small_z /122/
	logical up_case
	lower_to_upper=small_a-big_a
	up_case=.true.
	do i=1,length
		if (array(i).eq.quote) then
			up_case=.false.
			length=length-1
!
! swallow quote signs
!
			do j=i,length
				array(j)=array(j+1)
			 enddo
			array(length+1)=32
		 endif
		if (array(i).ge.small_a .and. array(i).le.small_z
     1			.and. up_case) 	array(i)=array(i)-
     2						lower_to_upper
 10		continue
 	 enddo
 9000	return
	end
