  	options /extend_source
	function dix_dump_screen(control,iterm,dis)
	implicit none
c
c Dump the data in the record data on the screen
c dependend on file.raw display in either interpreted mode, or in raw mode
c
	include 'dix_def.inc'
c
	record /control/ control	!:io: control area
	integer*4 iterm			!:o: typed key
	record /dis_pars / dis		!:i: display parameters
	integer*4 dix_dump_screen	!:f: function result
c#
	record /des_expanded/ des_expanded
	pointer (p_des_expanded,des_expanded)
c
	record /des_info/ des_info
	pointer (p_des_info,des_info)
c
	record /file_info/ file		!:i: file information
	pointer (p_file,file)
c
	record /dyn_help/ help_des
	record /link_rec/ link_rec
	record /value/ value
	character*(max_filename_length) link_fnam
	character*(max_short_line_length) line,context
	character*(max_line_length) err_arg
	integer*4 nk,new_wid,istat,nk_err,old_binary
	logical got_help,raw_mode
	logical changed_des,changed_rec
	logical changed_fil,in_vfc
c
	integer*4 dix_util_get_len_fu
	logical*4 dix_rms_delete
	integer*4 dix_rms_get
	integer*4 dix_rms_read_prev_rec_rel
	integer*4 dix_rms_read_prev_rec_idx
	integer*4 dix_main_get_rec_int
	integer*4 dix_dump_s_get_keys
	integer*4 dix_main_follow
	integer*4 dix_main_follow_back
	integer*4 dix_search_search_file
	integer*4 dix_dump_get_rfa
c
	external dix_msg_nodescr
	external dix_msg_datarest
	external dix_msg_notinmod
c
	integer*4 max_rfas,n_rfas
	parameter (max_rfas=2)
	record /rfa/ rfas(max_rfas)
c
	include '($smgdef)'
c
	character*(*) context_raw
	character*(*) context_des
	parameter (context_raw = 'SHOWRAW')
	parameter (context_des = 'SHOWDES')
c
	got_help = .false.
	istat = 1
	in_vfc = .false.
c
	raw_mode = dis.raw
c
c On the SMG we cannnot print binary data, so if the binary print
c  is set to _bin, replace by _dot
c
	old_binary = control.include_binary
	if(control.include_binary .eq. include_binary_bin) 
     1        control.include_binary = include_binary_dot
c
c Take the current file
c
	call dix_eval_init_value(value)
1	p_file = control.cur_file
        call dix_symbol_add_str(control,'$FILE',
     1                      file.fnam(1:file.nk_fnam),line)
c
c Update the header line 1
c
	call dix_dump_screen_display_hdr_1(control,file)
c
c Now take the current description (if any)
c             
5	if(file.cur_des .eq. 0) file.cur_des = file.top_des
	p_des_expanded = file.cur_des
	if(p_des_expanded .ne. 0) then
	  p_des_info = des_expanded.p_des_info
	  if(des_expanded.expand_error) p_des_expanded = 0
	else
	  p_des_info = 0
	endif
c
c Create header display
c
	if(.not. raw_mode .and. p_des_expanded .eq. 0) then
c
c Check on impossible things
c
	  call dix_message(control,dix_msg_nodescr)
	  raw_mode = .true.
	end if
c
c Build help, remove if we had one
c
	if(got_help) then
	  call dix_smg_unstack_help(control)
	  call help_exit(help_des)
	end if
c
	if(raw_mode) then
	  context = context_raw
	else
	  context = context_des
	endif
c
	call get_help_lines(control,help_des,raw_mode,
     1                      file.top_des .ne. 0,context)
	call dix_smg_stack_help(control,help_des)
	got_help = .true.
c
c
20	changed_des = .false.
	changed_fil = .false.
c
c Save the DIXRFA pointer for the current record
c
	call dix_rms_save_rfa_std(file)
c
	if(raw_mode) then
c
c Display in raw mode
c
	  call dix_dump_screen_raw(control,iterm,dis,file,in_vfc,context)
	else
c
c Dump in description mode
c
	  if(p_des_info .eq. 0) then
	    nk = 0
            call dix_symbol_add_str(control,'$DESCRIPTION',line(1:nk),line)
	  else
            call dix_symbol_add_str(control,'$DESCRIPTION',
     1                  des_info.fnam(1:des_info.nk_fnam),line)
	  endif
	  call dix_dump_screen_des(control,des_info,des_expanded,iterm,
     1        dis,file,link_rec,value,link_fnam,in_vfc,context)
	end if
c
c check on command's
c
	if(iterm .eq. key_swap_dis) then		!toggle raw/interp
	  raw_mode = .not. raw_mode
c
c Now build new help
c
	  changed_des = .true.
	elseif(iterm .eq. key_abort) then		!restore record
	  if(file.modify) then
	    file.data.nb_data = file.data.nb_sav                    !from original read-in
	    call dix_util_copy(file.data.nb_data,file.data.data_sav,
     1                       file.data.data_rec)
	    call dix_message(control,dix_msg_datarest,%val(file.data.nb_data),
     1          %descr('UNDO_AREA'))
	    changed_rec = .true.
	  endif
	elseif(iterm .eq. key_restore) then
	  if(file.modify) then
	    call dix_smg_copy_restore(control,control.nb_save,control.save_area,
     1                      file.data.nb_data,file.data.data_rec)
	  else
	    call dix_message(control,dix_msg_notinmod)
	  endif
	elseif(iterm .eq. key_dirdes) then              !display descriptions
	  call dix_smg_sel_dirs(control,file)		!and let user select
	  changed_des = .true.	
	elseif(iterm .eq. key_nextdes) then             !take next description
	  if(p_des_info .eq. 0) then
	    call dix_message(control,dix_msg_nodescr)
	  else
	    p_des_expanded = des_expanded.link.forw
	    if(p_des_expanded .eq. 0) p_des_expanded = file.top_des
	    file.cur_des = p_des_expanded
	    changed_des = .true.	
	  end if
	elseif(iterm .eq. key_prevdes) then             !take previous descrip
	  if(p_des_info .eq. 0) then
	    call dix_message(control,dix_msg_nodescr)
	  else
	    p_des_expanded = des_expanded.link.backw
	    if(p_des_Expanded .eq. 0) then
	      p_des_expanded = file.top_des
	      do while(des_expanded.link.forw .ne. 0)
	        p_des_expanded = des_expanded.link.forw
	      end do
	    end if
	    file.cur_des = p_des_expanded
	    changed_des = .true.
	  end if
	elseif(iterm .eq. key_remove) then              !delete record
	  istat = dix_rms_delete(control,file)
	  changed_rec = .true.
	elseif(iterm .eq. key_ch_width) then              !delete record
	  if(control.ncols .le. norm_screen_width) then
	    new_wid = max_screen_width
	  else
	    new_wid = norm_screen_width
	  endif
	  call smg$change_pbd_characteristics(control.paste_id,new_wid)
	  control.ncols = new_wid
          call smg$change_virtual_display(control.dis_kop,,new_wid)
	  call dix_dump_screen_display_hdr_1(control,file)
	elseif(iterm .eq. key_prev_file) then
          p_file = file.link.backw
          if(p_file .eq. 0) then
            p_file = control.top_file
            do while(file.link.forw .ne. 0)
              p_file = file.link.forw
            end do
          endif
	  control.cur_file = p_file
	  changed_fil = .true.
	elseif(iterm .eq. key_next_file) then
          control.cur_file = file.link.forw
          if(control.cur_file .eq. 0) control.cur_file = control.top_file
	  changed_fil = .true.
	elseif(iterm .eq. key_dir_file) then
	  call dix_smg_sel_files(control)
	  changed_fil = .true.
	elseif(iterm .eq. key_next_rec) then
	  istat = dix_rms_get(control,file)
	  if(.not. istat) call dix_message(control,%val(istat))
	  changed_rec = .true.
	elseif(iterm .eq. key_prev_rec) then
          if(file.block_size .ne. 0) then
c
c Block mode, get the previous block (rec)
c
            istat = dix_main_get_rec_int(control,file,file.rec_nr-1)
          else
	    if(file.indexed) then
	      istat = dix_rms_read_prev_rec_idx(control,file)
	    elseif(file.relative) then
	      istat = dix_rms_read_prev_rec_rel(control,file)
	    else
              istat = dix_main_get_rec_int(control,file,file.rec_nr-1)
	    endif
	    changed_rec = .true.
          end if
	  if(.not. istat) call dix_message(control,%val(istat))
	elseif(iterm .eq. key_find_rec .or. iterm .eq. key_find_rec1) then
c	  if(iterm .eq. key_find_rec1) control.n_search = 0
	  call dix_main_check_mod_record(control,file)
	  istat = dix_search_search_file(control,file,.false.,
     1                 max_rfas,rfas,n_rfas,iterm .eq. key_find_rec1)
	  if(istat) istat = dix_dump_get_rfa(control,file,rfas(2))
	  changed_rec = .true.
	elseif(iterm .eq. key_ask_key) then
	  istat = dix_dump_s_get_keys(file,control)
	  if(.not. istat) call dix_message(control,%val(istat))
	  changed_rec = .true.
	elseif(iterm .eq. key_put) then
	  call dix_main_fill_rec(control,file)
	  file.data.newrec = .true.
	  changed_rec = .true.
	elseif(iterm .eq. key_follow_link) then
	  istat = dix_main_follow(control,.false.,0,link_rec,
     1               value,link_fnam,err_arg)
	  nk_err = dix_util_get_len_fu(err_arg)
	  if(.not. istat) call dix_message(control,%val(istat),
     1         err_arg(1:nk_err))
	  changed_fil = .true.
	elseif(iterm .eq. key_back_link) then
	  istat = dix_main_follow_back(control,.true.)
	  if(.not. istat) call dix_message(control,%val(istat))
	  changed_fil = .true.
	elseif(iterm .eq. key_exit) then
	  goto 90
	elseif(iterm .eq. key_modechange) then
	  goto 90
	end if
c
	if(changed_rec) then
	  call dix_des_inv_des(control,file)
	  changed_des = .true.
	endif
	if(changed_fil) goto 1
	if(changed_des) goto 5
	goto 20
c
c Remove the help from this module
c
90	istat = 1
	call dix_smg_unstack_help(control)
	call help_exit(help_des)
	call dix_eval_free_value(value)
	control.include_binary = old_binary
	dix_dump_screen = istat
	return
	end

	subroutine dix_dump_screen_des(control,des_info,des_Expanded,iterm,
     1                   dis,file,link_rec,value,link_fnam,
     1                   in_vfc,context)
	implicit none
c
c Display the data via the descriptions
c
c
	include 'dix_def.inc'
	include 'dix_screen_def.inc'
c
	record /control/ control	!:io: control structure
	record /des_info/ des_info	!:i: description file information
	record /des_expanded/ des_expanded !:i: expanded des
	integer*4 iterm			!:o: terminator
	record /dis_pars/  dis		!:i: display parameters
	record /file_info/ file		!:i: file information
	record /link_rec/ link_rec	!:o: the link record for follow_link
	record /value/ value		!:o: the value or the follow_link
	logical*4 in_vfc		!:io: vfc mode?
	character*(*) link_fnam		!:o: the file name for the follow_link
	character*(*) context		!:i: the context (screen) name
c#
	include '($smgdef)'
c
	record /des_rec/ des_recs(*)
	pointer (p_des_recs,des_recs)
c
	integer*4 k,l,nk,dis_cont,bit_offset,m
	integer*4 line_nr,krow,kcol
	integer*4 max_len,istat
	integer*4 i_des
	logical*4 top,repaint,readonly,modified
c
c
	character*(max_screen_width) line
	byte temp_data(max_buf)
c
	character*(max_command_length) regel,vid_line
	integer*4 nkar,nlin,dis_id_bar
	integer*4 ibpos,iepos,n_des_recs
c
	logical*4 dix_dump_in_modify
	integer*4 dix_dump_set_link
	logical*4 dix_con_typ_is_text
	logical*4 dix_des_expand
	logical*4 dix_util_kar_in_ran
	integer*4 dix_util_get_len_fu
	logical dix_smg_select_field
	integer*4 dix_rms_update
	logical dix_dump_check_deposit
c
	external dix_msg_swcomp
	external dix_msg_nodata
	external dix_msg_novfc
	external dix_msg_recempty
	external dix_msg_nofields
	external dix_msg_reclchg
	external dix_msg_rectrunc
c	external dix_msg_debug
c
	record /display_data_des/ disp_dat
	record /display_data_des/ disp_vfc
	record /display_data_des/ disp
	pointer (p_disp,disp)
c
c Fill header display
c
	disp_dat.magic = magic_display_data_des
	disp_vfc.magic = magic_display_data_des
	call dix_des_display_width(control,des_info,line,nk,
     1                control.ncols-20)
c
	line(nk+1:) = ' '
        call smg$put_chars(control.dis_kop,
     1           'Des file :',3,1,,smg$m_reverse)
        call smg$put_chars(control.dis_kop,line,3,11,,
     1            smg$m_bold .or. smg$m_reverse)
	dis_id_bar = 0
c
3	line_nr = 1
	
	disp_dat.screen.row_offset = 1
	disp_dat.screen.col_offset = 1
	disp_dat.screen.col = 1
c
5	nk = 0
c
c Update the 2nd line (recsiz,recnr, and RFA)
c 
	call dix_dump_screen_display_hdr_2(control,file,dis)
c
c Try to expand the descriptions, if error go back to raw mode
c
	if(.not. dix_des_expand(control,des_expanded,file,.false.)) then
	  iterm = key_swap_dis
	  goto 90
	end if
c
c If compressed mode wanted, compress it now
c
c
	if(dis.compres) then
	  disp_dat.n_des = des_expanded.nfield_notcompressed
	else
	  disp_dat.n_des = des_expanded.table_nor.count
	endif	  
c
c If no lines from expand, check for compress mode, 
c   if on , reset and try again
c
	if(disp_dat.n_des .eq. 0) then
	  if(dis.compres) then
	    call dix_message(control,dix_msg_swcomp)
	    dis.compres = .false.
	    disp_dat.n_des = des_expanded.table_nor.count
	  end if
	endif
	if(disp_dat.n_des .eq. 0) then
	  call dix_message(control,dix_msg_nodata)
	end if
c
	if(dis.compres) then
	  line = 'Comprs'
	else
	  line = 'Norm'
	end if
c
	call smg$put_chars(control.dis_kop,line(1:6),2,34,,
     1             smg$m_bold .or. smg$m_reverse)
c
c Create display big enough (if not it will be increased later)
c
	disp_dat.screen.disp_nrows = 2*disp_dat.n_des+4
	disp_dat.screen.disp_ncols = control.ncols
	call smg$create_virtual_display(disp_dat.screen.disp_nrows,
     1           disp_dat.screen.disp_ncols,disp_dat.dis_id)
c
	call smg$create_virtual_display(disp_dat.screen.disp_nrows,
     1           disp_dat.screen.disp_ncols,disp_dat.dis_id_offset)
c
c
c go display all data
c
7	call dix_dump_Screen_display_scr(control,disp_dat,
     1        des_expanded,.false.,dis,file,des_info.has_fields)
c
c Now create viewport, save 3 lines for the header
c  if vfc present, save 3 line more for vfc display
c   (1 for header and 2 for data)
c
	disp_dat.screen.view_nrows = control.nrows-3
c
	if(file.data.nb_vfc .ne. 0) then
c
c There is vfc data, reserve 3 lines for the vfc display
c
	  disp_dat.screen.view_nrows = disp_dat.screen.view_nrows - 3
c
c And create the vfc display
c
	  disp_vfc.screen.disp_nrows = file.data.nb_vfc
	  disp_vfc.screen.disp_ncols = control.ncols
	  disp_vfc.screen.view_nrows = 2
	  disp_vfc.screen.row_offset = 1
	  disp_vfc.screen.col_offset = 1
	  disp_vfc.screen.col = 1
c
	  call smg$create_virtual_display(disp_vfc.screen.disp_nrows,
     1                                    disp_vfc.screen.disp_ncols,
     1                                    disp_vfc.dis_id)
	  call smg$create_virtual_display(disp_vfc.screen.disp_nrows,
     1                                    disp_vfc.screen.disp_ncols,
     1                                    disp_vfc.dis_id_offset)
	  call smg$create_virtual_display(1,control.ncols,dis_id_bar)
C                                      
	  call dix_dump_Screen_display_scr(control,disp_vfc,
     1           des_expanded,.true.,dis,file,des_info.has_fields)
c
c Display the real data
c
	  call smg$create_viewport(disp_vfc.dis_id,
     1                             disp_vfc.screen.row_offset,
     1                             disp_vfc.screen.row_offset,
     1                             disp_vfc.screen.view_nrows,
     1                             disp_vfc.screen.view_ncols)
	  disp_vfc.screen.paste_row = control.nrows-1
	  disp_vfc.screen.paste_col = disp_vfc.ncol_offset+1
	  call smg$paste_virtual_display(disp_vfc.dis_id,control.paste_id,
     1                     disp_vfc.screen.paste_row,
     1                     disp_vfc.screen.paste_col)
c
c Display the offset data
c
	  call smg$create_viewport(disp_vfc.dis_id_offset,
     1                             disp_vfc.screen.row_offset,
     1                             disp_vfc.screen.col_offset,
     1                             disp_vfc.screen.view_nrows,
     1                             disp_vfc.ncol_offset) 
	  call smg$paste_virtual_display(disp_vfc.dis_id_offset,
     1                     control.paste_id,
     1                     disp_vfc.screen.paste_row,1)
c
	  call smg$paste_virtual_display(dis_id_bar,control.paste_id,
     1                     disp_vfc.screen.paste_row-1,1)
c
c Draw a separating line
c
	  call smg$draw_line(dis_id_bar,1,1,1,control.ncols)
	  call smg$put_chars(dis_id_bar,'VFC Data',1,10)
	else
	  disp_vfc.dis_id = 0
	endif
c
	call smg$create_viewport(disp_dat.dis_id,
     1                           disp_dat.screen.row_offset,
     1                           disp_dat.screen.col_offset,
     1                           disp_dat.screen.view_nrows,
     1                           disp_dat.screen.view_ncols)
	disp_dat.screen.paste_row = 4
	disp_dat.screen.paste_col = disp_dat.ncol_offset+1
	call smg$paste_virtual_display(disp_dat.dis_id,control.paste_id,
     1              disp_dat.screen.paste_row,
     1              disp_dat.screen.paste_col)
c
	call smg$create_viewport(disp_dat.dis_id_offset,
     1                           disp_dat.screen.row_offset,
     1                           disp_dat.screen.col_offset,
     1                           disp_dat.screen.view_nrows,
     1                           disp_dat.ncol_offset) 
c
	call smg$paste_virtual_display(disp_dat.dis_id_offset,
     1                control.paste_id,
     1                disp_dat.screen.paste_row,1)
c
c If continouous description display wanted, create it now
c
	if(dis.show_des) call smg$create_virtual_display(1,1,dis_cont)
c
	if(in_vfc) then
	  p_disp = %loc(disp_vfc)
	else
	  p_disp = %loc(disp_dat)
	endif
c
c
c Start editting./displaying,
c compute requested row, and make sure its in screen
c
10	if(disp.screen.nlines .gt. 0) then
c
c Get the correct des_rec. It is the line_nr'th one if not comnpressed
c   or the line_nr'th uncompressed one
c
	  i_des = disp.admins(line_nr).idx_des
	  if(in_vfc) then
	    n_des_recs = des_expanded.table_vfc.count
	    p_des_recs = des_expanded.table_vfc.address
	  else
	    n_des_recs = des_expanded.table_nor.count
	    p_des_recs = des_expanded.table_nor.address
	  endif
	  disp.screen.row = disp.admins(line_nr).row_number
c
c Check for the readonly case
c
	  readonly = (des_recs(i_des).flags .and. des_flag_readonly) .ne. 0
	  bit_offset = des_recs(i_des).bit_offset
	else
	  line_nr = 0
	  disp.screen.row = 1
	  bit_offset = 0
	end if
c
c Display description if wanted
c
	if(dis.show_des) then
	  top = (disp.screen.row-disp.screen.row_offset) .gt. 
     1           (disp.screen.view_nrows/2)
	  call display_des(control,dis_cont,des_recs(i_des),top,0)
	end if
c
c Get key
c
	l = max(1,disp.screen.view_nrows-disp.admins(line_nr).nlines)
c
	call dix_dump_get_key(control,disp.dis_id,disp.dis_id_offset,
     1                        disp.screen,l,
     1                        iterm,dis,
     1                        bit_offset,
     1                        file,.true.,des_info.has_fields,
     1                        krow,kcol,context,.false.)
	if(iterm .eq. key_mouse_left) then
c
c Go to the wanted item
c
	  call dix_dump_Screen_set_ptr_des(control,krow,disp_dat,disp_vfc,
     1                                     in_vfc,line_nr,p_disp)
	  i_des = disp.admins(line_nr).idx_des
	  readonly = (des_recs(i_des).flags.and.des_flag_readonly).ne.0
	  bit_offset = des_recs(i_des).bit_offset
	  goto 10
c
	elseif(iterm .eq. key_mouse_middle) then
c
c Scroll up/down (in vfc and normal window)
c
	  if(krow .lt. disp.screen.view_nrows/2) then
	    iterm = key_prev
	  else
	    iterm = key_next
	  endif
	elseif(iterm .eq. key_mouse_right .or. iterm .eq. key_menu) then
c
c Menu options
c
	  if(iterm .eq. key_mouse_right) then
	    call dix_dump_Screen_set_ptr_des(control,krow,disp_dat,disp_vfc,
     1                                     in_vfc,line_nr,p_disp)
	    i_des = disp.admins(line_nr).idx_des
	    readonly   = (des_recs(i_des).flags.and.des_flag_readonly).ne.0
	    bit_offset = des_recs(i_des).bit_offset
	  endif
	  nk = 0
	  call dix_append(nk,line,'Compress,Top,Bot,Follow,'//
     1              'Displaydes,Raw,Wide,All_formats,Backfollow,'//
     1              'NextRec,PrevRec,FieldEdit')
	  if(file.link.forw  .ne. 0) call dix_append(nk,line,',NextFile')
	  if(file.link.backw .ne. 0) call dix_append(nk,line,',PrevFile')
	  if(file.link.forw .ne. 0 .or. file.link.backw .ne. 0) then
	    call dix_append(nk,line,',DirectoryFile')
	  endif
	  if(des_expanded.link.forw  .ne. 0) call dix_append(nk,line,
     1                                      ',NextDescript')
	  if(des_expanded.link.backw .ne. 0) call dix_append(nk,line,
     1                                      ',PrevDescript')
	  if(des_expanded.link.forw .ne. 0 .or. 
     1       des_expanded.link.backw .ne. 0) then
	    call dix_append(nk,line,',DirectoryDescript')
	  endif
c	
	  if(file.indexed) then
	    call dix_append(nk,line,',KeyedRead')
	  else
	    call dix_append(nk,line,',RecordRead')
	  endif
	  if(dis.hex .ne. des_flag_translate_nor) then
	    call dix_append(nk,line,',Decimal data')	  
	  endif
	  if(dis.hex .ne. des_flag_translate_hex) then
	    call dix_append(nk,line,',Hex data')	  
	  endif
	  if(dis.hex .ne. des_flag_translate_oct) then
	    call dix_append(nk,line,',Octal data')	  
	  endif
	  if(dis.hex .ne. des_flag_translate_bin) then
	    call dix_append(nk,line,',Binary data')	  
	  endif
c
	  if(dis.number_hex) then
	    call dix_append(nk,line,',Decimal offset')	  
	  else
	    call dix_append(nk,line,',Hex offset')	  
	  endif
c
c Pasted at row 4
c
	  call dix_smg_select_menu(control,line(1:nk),line,
     1          .false.,'Choises',
     1          disp.screen.row+3,disp.screen.col,.true.)
c
	  if(    line(1:1) .eq. 'A') then
	    iterm = key_dispall
	  elseif(line(1:2) .eq. 'BA') then
	    iterm = key_back_link
	  elseif(line(1:2) .eq. 'BO') then
            iterm = key_bot
	  elseif(line(1:2) .eq. 'BI') then
	    iterm = key_display_binary
	  elseif(line(1:1) .eq. 'C') then
            iterm = key_compres
	  elseif(line(1:3) .eq. 'DEC') then
	    iterm = key_display_decimal
	  elseif(line(1:3) .eq. 'DIS') then
	    iterm = key_contdis
	  elseif(line(1:10) .eq. 'DIRECTORYF') then
	    iterm = key_dir_file
	  elseif(line(1:10) .eq. 'DIRECTORYD') then
	    iterm = key_dirdes
	  elseif(line(1:2) .eq. 'DE') then
	    if(index(line,'OFFSET') .ne. 0) iterm = key_hexdeco
	    if(index(line,'DATA') .ne. 0) iterm = key_display_hex
	  elseif(line(1:1) .eq. 'F') then
c
c For this one only, set the current field to this field
c
	    if(iterm .eq. 'O') then
	      iterm = key_follow_link
	    else
	      iterm = key_getfields
	    endif	
	  elseif(line(1:1) .eq. 'H') then
	    if(index(line,'OFFSET') .ne. 0) iterm = key_hexdeco
	    if(index(line,'DATA') .ne. 0)   iterm = key_display_hex
	  elseif(line(1:5) .eq. 'NEXTR') then
	    iterm = key_next_rec
	  elseif(line(1:5) .eq. 'NEXTF') then
	    iterm = key_next_file
	  elseif(line(1:5) .eq. 'NEXTD') then
	    iterm = key_nextdes
	  elseif(line(1:1) .eq. 'K') then
	    iterm = key_ask_key
	  elseif(line(1:1) .eq. 'O') then
	    iterm = key_display_octal
	  elseif(line(1:2) .eq. 'RE') then
	    iterm = key_ask_key
	  elseif(line(1:2) .eq. 'RA') then
	    iterm = key_swap_dis
	  elseif(line(1:5) .eq. 'PREVR') then
	    iterm = key_prev_rec
	  elseif(line(1:5) .eq. 'PREVF') then
	    iterm = key_prev_file
	  elseif(line(1:5) .eq. 'PREVD') then
	    iterm = key_prevdes
	  elseif(line(1:1) .eq. 'T') then
            iterm = key_top
	  elseif(line(1:1) .eq. 'W') then
	    iterm = key_ch_width
	  else
	    iterm = 0
	  endif
	  if(iterm .eq. 0) goto 10	
	endif
c
c Go exectute the commands
c
	if(iterm .eq. key_prev) then
	  do while(line_nr .gt. 1 .and. 
     1            disp.admins(line_nr).row_number .gt. 
     1            disp.screen.row-disp.screen.view_nrows+2)
	    line_nr = line_nr -1
	  end do
	elseif(iterm .eq. key_next) then
	  do while(line_nr .lt. disp.n_des .and. 
     1            disp.admins(line_nr).row_number .lt. 
     1            disp.screen.row+disp.screen.view_nrows-2)
	    line_nr = line_nr +1
	  end do
	elseif(iterm .eq. key_top) then
	  line_nr = 1
	elseif(iterm .eq. key_bot) then
	  line_nr = disp.n_des
	elseif(iterm .eq. key_up) then
	  if(line_nr .gt. 1) line_nr = line_nr-1
	elseif(iterm .eq. key_down) then
	  if(line_nr .lt. disp.n_des) line_nr = line_nr+1
	elseif(iterm .eq. key_contdis) then
	  if(dis.show_des) then
	    call smg$delete_virtual_display(dis_cont)
	  else
	    call smg$create_virtual_display(1,1,dis_cont)
	  end if
	  dis.show_des = .not. dis.show_des
	elseif(iterm .eq. key_dispall) then
	  if(disp.screen.nlines .eq. 0) goto 79
	  call dix_dump_display_all(control,bit_offset,file.data.data_rec,
     1                              file.data.nb_data,file,
     1                              modified,.true.,' ')
	  if(modified) iterm = key_chdis
	elseif(iterm .eq. key_viewvfc) then
	  if(file.data.nb_vfc .gt. 0) then
	    in_vfc = .not. in_vfc
	    if(in_vfc) then
	      p_disp = %loc(disp_vfc)
	    else
	      p_disp = %loc(disp_dat)
	    endif	     
	  else
	    call dix_message(control,dix_msg_novfc)
	  endif
	elseif(iterm .eq. key_save) then
	  call dix_smg_copy_save(control,file.data.nb_data,file.data.data_rec,
     1                           control.nb_save,control.save_area)
	elseif(iterm .eq. key_find) then
c
c Find last description just before row
c
	  do k=1,disp.n_admins
	    if(disp.admins(k).row_number .ge. disp.screen.row) goto 60
	  end do
	  k = disp.n_des
60	  line_nr = k
	elseif(iterm .eq. key_do) then
c
c Update patches
c
	  istat = dix_rms_update(control,file,.true.)
	  if(.not. istat) call dix_message(control,%val(istat))
	elseif(iterm .eq. key_viewdesc) then           !view expanded des
	  call dix_dump_screen_view_des(control,des_info)
	elseif(iterm .eq. key_viewdes) then
	  call dix_smg_view_des_file(control,des_info)
	elseif(iterm .eq. key_back_link) then
	  goto 90
	elseif(iterm .eq. key_follow_link) then
	  k = dix_dump_set_link(control,i_des,
     1          %val(des_expanded.table_nor.address),
     1          line,file,.true.,
     1          link_rec,value,link_fnam)
	  if(k) then
	    iterm = key_follow_link
	    goto 90
	  else
	    nk = dix_util_get_len_fu(line)
	    call dix_message(control,%val(k),line(1:nk))
	  endif
	elseif(iterm .eq. key_first) then
	  disp.screen.col = 1
	elseif(iterm .eq. key_last) then
	  disp.screen.col = disp.screen.ncols - disp.screen.view_ncols+1
	elseif(iterm .eq. key_right) then
	  disp.screen.col = min(disp.screen.col + 10,
     1              disp.screen.ncols - disp.screen.view_ncols+1)
	elseif(iterm .eq. key_left) then
	  disp.screen.col = max(1,disp.screen.col - 10)
	elseif(iterm .le. key_chdis) then
	  goto 90
	else
	  if(disp.screen.nlines .eq. 0) goto 79
	  if(dix_util_kar_in_ran(iterm) .or. 
     1       iterm .eq. key_enter .or.
     1       iterm .eq. key_getfields .or.
     1       iterm .eq. key_erase) then
c     1       iterm .eq. key_right .or.
c
c Character insert mode
c Get the string
c
	    nk = len(regel)
	    if (.not. dis.hex .and. 
     1          dix_con_typ_is_text(des_recs(i_des).ent_type)) then
	      if((des_recs(i_des).flags .and. des_flag_is_variable).eq.0) then
	        nk = des_recs(i_des).size/bits_per_byte - 
     1            (des_recs(i_des).flags.and.des_flag_nb_reserved_mask)
	      end if
	    end if
c
c If getfields, process it
c 
	    if(iterm .eq. key_getfields) then
	      k = des_recs(i_des).flags .and. des_flag_fieldname_status_mask
	      if(des_recs(i_des).fldnam.dsc$w_maxstrlen .ne. 0 .and. 
     1          k .ne. des_flag_fieldname_status_none) then
c
c field entry allowed
c	        
	        if(in_vfc) then
                  call dix_util_copy_bits(des_recs(i_des).size,
     1              des_recs(i_des).bit_offset,
     1              file.data.vfc_data,temp_data,sizeof(temp_data))
	        else
                  call dix_util_copy_bits(des_recs(i_des).size,
     1              des_recs(i_des).bit_offset,
     1              file.data.data_rec,temp_data,sizeof(temp_data))
	        endif
c
	        if(dix_smg_select_field(control,temp_data,
     1           des_recs(i_des).size,
     1           k .ne. des_flag_fieldname_status_singl,
     1           des_recs(i_des).fldnam,
     1           k .eq. des_flag_fieldname_status_mulrv,
     1           file.modify,readonly)) then
c
c select field oke, insert the data in the buffer
c
	          if(.not. file.modify) goto 10
c
c Do not modify
c 
	          call dix_util_insert_bits(temp_data,
     1                des_recs(i_des).bit_offset,
     1                des_recs(i_des).size,file.data.data_rec)
c
c Now compute new #lines
c
	          call dix_con_intasc(file.data.nb_data-
     1              des_recs(i_des).bit_offset/bits_per_byte,
     1              des_recs(i_des),file.data.data_rec,regel,nkar,
     1              dis.hex,max_len,control)
c
	          if(control.wide_display) then
	            nlin = 1
	          else
	            nlin = max(1,(nkar+disp.screen.view_ncols-1)/
     1                             disp.screen.view_ncols)
	          endif
	          k = nlin-disp.admins(line_nr).nlines
	          if(k .lt. 0) then
c
c Delete some display lines
c
	            call smg$delete_line(disp.dis_id,disp.screen.row+1,-k)
	            call smg$delete_line(disp.dis_id_offset,
     1                                   disp.screen.row+1,-k)
	          elseif(k .gt. 0) then
c
c Insert Delete some display lines
c
	            line = ' '
	            do l=1,k
	              m = disp.screen.view_ncols
	              line(disp.screen.col+1:) = regel((k-1)*m+1:k*m)
	              call smg$insert_line(disp.dis_id,disp.screen.row+
     1                     disp.admins(line_nr).nlines,
     1                     line,smg$m_down)
	              call smg$insert_line(disp.dis_id_offset,disp.screen.row+
     1                     disp.admins(line_nr).nlines,
     1                     line,smg$m_down)
	            end do
	            call smg$draw_line(disp.dis_id_offset,
     1                                 disp.screen.row,
     1                                 disp.screen.col-1,
     1                                 disp.screen.row+k,
     1                                 disp.screen.col-1)
	            if(dis.number) call smg$draw_line(disp.dis_id_offset,
     1                  disp.screen.row,disp.nk_off+1,
     1                  disp.screen.row+k,disp.nk_off+1)
	          endif
	        else
	          goto 10
	        endif
	      else
	        call dix_message(control,dix_msg_nofields)
	        goto 10      
	      endif
	    else
	      if(.not. dix_dump_in_modify(control,file.modify,
     1                                    readonly)) goto 10
	      if((des_recs(i_des).flags.and.des_flag_readonly) .ne. 0) goto 10
c
c let the user edit the data,  get ascii data in regel
c
	      if(in_vfc) then
	        call dix_con_intasc(file.data.nb_vfc-
     1             des_recs(i_des).bit_offset/bits_per_byte,
     1             des_recs(i_des),file.data.vfc_data,regel,nkar,
     1             dis.hex,max_len,control)
	      else
	        call dix_con_intasc(file.data.nb_data-
     1             des_recs(i_des).bit_offset/bits_per_byte,
     1             des_recs(i_des),file.data.data_rec,regel,nkar,
     1             dis.hex,max_len,control)
	      endif
	      nlin = disp.admins(line_nr).nlines
c
c Replace binary zero's by .
c  the binary_dot transformation will insert char(0) for unprintables
c
	      do k=1,nkar
	        if(regel(k:k) .eq. char(0)) regel(k:k) = '.'
	      end do
	      l = 0                
	      if(dis.number) l = disp.nk_off +1
	      if(max_len .gt. nkar) regel(nkar+1:max_len) = ' '
	      call dix_smg_get_string_multi(control,disp.dis_id,
     1                        disp.dis_id_offset,
     1                        disp.screen.row,
     1                        disp.screen.col,nlin,
     1                        disp.screen.view_ncols,
     1                        regel(1:max_len),
     1                        0,iterm,nkar,
     1                        disp.ncol_offset,
     1                        disp.nk_off,
     1                        disp.screen.col_offset,
     1                        disp.screen.disp_ncols,
     1                        disp.screen.row_offset,
     1                        disp.screen.view_nrows)
	    endif
c
c If editting changed #lines for convert, adapt all des_recs for line_nr
c
	    if(nlin .ne. disp.admins(line_nr).nlines) then
c
c Display length has changed
c Patch all following descriptions to new index on screen
c
	      l = disp.admins(line_nr).nlines - nlin		!so much changed
	      disp.admins(line_nr).nlines = nlin
c
	      do k=line_nr+1,disp.n_admins
	        disp.admins(k).row_number = disp.admins(k).row_number - l
	      end do
	    end if
c                          
	    call dix_dump_check_deposit(control,file,des_recs(i_des),
     1                   n_des_recs,
     1                   des_recs,
     1                   regel(1:nkar),
     1                   dis,repaint,iterm .eq. key_getfields,in_vfc)
c
	    if(repaint) then
c
c SOmething changed, force recrod reexpansion
c
	      call dix_des_inv_des_file(control,file)
	      iterm = key_repaint
	      goto 90
	    endif
c
	    if(in_vfc) then
	      call dix_con_intasc(file.data.nb_vfc-
     1             des_recs(i_des).bit_offset/bits_per_byte,
     1             des_recs(i_des),file.data.vfc_data,regel,nkar,
     1             dis.hex,max_len,control)
	    else
	      call dix_con_intasc(file.data.nb_data-
     1             des_recs(i_des).bit_offset/bits_per_byte,
     1             des_recs(i_des),file.data.data_rec,regel,nkar,
     1             dis.hex,max_len,control)
	    endif
	    nlin = disp.admins(line_nr).nlines
c
c Map, in multiple lines
c
	    ibpos = 1
	    do l=1,nlin
	      iepos = nkar
	      if(.not. control.wide_display) then
	        iepos = min(iepos,l*disp.screen.view_ncols)
	      endif
	      disp.screen.ncols = max(disp.screen.ncols,iepos-ibpos+1)
c
	      do m=ibpos,iepos
	        if(regel(m:m) .eq. char(0)) then
	          regel(m:m) = '.'
	          vid_line(m-ibpos+1:m-ibpos+1) = char(smg$m_reverse)
	        else
	          vid_line(m-ibpos+1:m-ibpos+1) = char(0)
	        endif
	      end do
	      call smg$put_chars_multi(disp.dis_id,regel(ibpos:iepos),
     1                   l+disp.admins(line_nr).row_number-1,1,
     1                   smg$m_erase_to_eol,vid_line(1:iepos-ibpos+1))
	      ibpos = iepos+1
	    end do
c
c Conversion success
c
	  else
	    call dix_mes_invkey(control,context)
	  endif
78	end if
	goto 10
79	call dix_message(control,dix_msg_recempty)
	goto 10
90	if(iterm .eq. key_exit) then
	  if(file.data.nb_vfc .gt. 0) then
	    call smg$set_cursor_abs(disp_vfc.dis_id,
     1                 disp_vfc.screen.disp_nrows,1)
	  else
	    call smg$set_cursor_abs(disp_dat.dis_id,
     1                 disp_dat.screen.disp_nrows,1)
	  endif
	else
	  call smg$delete_virtual_display(disp_dat.dis_id)
	  call smg$delete_virtual_display(disp_dat.dis_id_offset)
	  if(file.data.nb_vfc .gt. 0) then
	    call smg$delete_virtual_display(disp_vfc.dis_id)
	    call smg$delete_virtual_display(disp_vfc.dis_id_offset)
	  endif
	endif
	if(iterm .eq. key_compres) then
	  dis.compres = .not. dis.compres
	  line_nr = 1
	  disp_dat.screen.row_offset = 1
	elseif(iterm .eq. key_change_disp) then
	  control.wide_display = .not. control.wide_display 
	endif
c
	if(iterm .gt. key_chmod) goto 5
	if(dis.show_des) call smg$delete_virtual_display(dis_cont)
	if(dis_id_bar .ne. 0) call smg$delete_virtual_display(dis_id_bar)
	return
	end
	subroutine dix_dump_Screen_set_ptr_des(control,krow,disp_dat,disp_vfc,
     1                                     in_vfc,line_nr,p_disp)
	implicit none
	include 'dix_def.inc'
	include 'dix_screen_def.inc'
c
c Process a setting of the current field when user enters a mouse_click
c
	record /control/ control	!:i: control block
	integer*4 krow			!:io: row number
	record /display_data_des/ disp_dat	!:i: info for data display
	record /display_data_des/ disp_vfc	!:i: info for vfc display
	logical*4 in_vfc		!:io: currenct vfc setting
	integer*4 line_nr		!:o: new line nr
	record /display_data_des/ disp	
	pointer (p_disp,disp)		!:io: pointer to correct data block
c#
	integer*4 k,l
c
c The display starts at line 3
c
	krow = krow - 3 
c
c See if the row is in the VFC display (if present)
c
	if(krow .gt. disp_dat.screen.view_nrows) then
c
c User pointed in vfc data
c
	  p_disp = %loc(disp_vfc)
	  krow = krow + 3 - control.nrows + 2 + disp.screen.row_offset - 1
	  in_vfc = .true.
	else
c
c User pointed in normal window
c
	  p_disp = %loc(disp_dat)
	  krow = krow + disp.screen.row_offset - 1
	  in_vfc = .false.
	endif
c
	l = line_nr
	do k=1,disp.n_des
	  if(krow .ge. disp.admins(k).row_number .and.
     1       krow .lt. disp.admins(k).row_number +
     1                 disp.admins(k).nlines) then
	    l = k
	  endif
	end do
	line_nr = l
c
c And set the row
c
	disp.screen.row = disp.admins(line_nr).row_number
	return
	end
	subroutine dix_dump_screen_dis_count(value,hex,dis_kop,row,col,fldmod,
     1           width,control)
	implicit none
c
	include 'dix_def.inc'
c
	integer*4 value
	logical*4 hex
	integer*4 dis_kop
	integer*4 row
	integer*4 col
	logical*4 fldmod
	integer*4 width
	record /control/ control
c#
	character*(max_short_line_length) line
	integer*4 nk
c
	include '($smgdef)'
c
	nk = 0
	call dix_util_con_nr(value,fldmod,line,nk,hex,control)
	if(hex) then
	  line = '%X'//line
	end if
	call smg$put_chars(dis_kop,line(1:width),row,col,,
     1                  smg$m_reverse.or.smg$m_bold)
	return
	end
	function display_des(control,dis_cont,des_rec,top,indent)
	implicit none
c
c Display the current description
c
	include 'dix_def.inc'
	record /control/ control
	integer*4 dis_cont		!:i: the (smg) display (0 if file)
	record /des_rec/ des_rec	!:i: the description record
	logical*4 top                   !:i: top or bottom of display
	integer*4 indent		!:i: indent wanted
	logical display_des		!:F: result of print_line
c#
	integer*4 wid,lent,needed_wid,needed_len,nk,nk1,l,k1,k2,lim,minl
	integer*4 infolen,k,maxl,nlext,row,needed_row,idx_line,nb1
	record /strdef/ fld_des
	integer*4 conmask
	logical*4 first,redis,one_line
	logical draw_file,draw_compute,draw_if
	character*(max_screen_width) line
	character kar
c
	logical dix_dump_print_line
	character*(max_tf_asc_length) dix_util_tfas
	integer*4 dix_util_get_len_fu
c
	record /link_rec/ link_rec
	pointer (p_link_rec,link_rec)
c
	record /des_rec_fil/ des_rec_fil
	pointer (p_des_rec_fil,des_rec_fil)
c
c
	include '($smgdef)'
c
	infolen = 11
	display_des = .false.
c
c For screen mode, we must run 2 times
c  1. compute #lines needed and adjust display if <> computed
c  2. disply the data
c
	lim = 1
	if(dis_cont .ne. 0) lim = 2
c
	needed_wid = 0
	needed_len = 4
	draw_file    = .false.
	draw_compute = .false.
	draw_if      = .false.
c
	do k=1,lim
	  if(k .eq. 2) then
c
c Second around, only for screen display
c get current display length
c
	    call smg$get_display_attr(dis_cont,lent,wid)
	    first = lent .eq. 1
c
	    if(top) then
	      needed_row = 5
	    else
	      needed_row = control.nrows-needed_len-1 !leave lowest line free
	    end if
c
c See if still at the correct place
c
	    call smg$get_pasting_info(dis_cont,control.paste_id,l,row)
	    redis = (row .eq. 5) .xor. (needed_row .eq. 5)
c
c Check if redisplay wanted
c
	    if(redis .or.(wid .ne. needed_wid+infolen).or.
     1                   (lent .ne. needed_len)) then
	      lent = needed_len
	      wid = needed_wid+infolen
	      row = needed_row
	      call smg$change_virtual_display(dis_cont,lent,wid,smg$m_border)
	      if(first) then
	       call smg$paste_virtual_display(dis_cont,control.paste_id,
     1                row,control.ncols-wid+1)
	      else
	        call smg$repaste_virtual_display(dis_cont,control.paste_id,
     1                row,control.ncols-wid+1)
	      end if
	    end if
	    call  smg$erase_display(dis_cont)
	    call smg$label_border(dis_cont,'Description')
	    call smg$put_chars(dis_cont,'Type'      ,1,1)
	    call smg$put_chars(dis_cont,'Variable',  2,1)
	    call smg$put_chars(dis_cont,'Dependency',3,1)
	    minl = 4
	    if(draw_file) then
	      call smg$put_chars(dis_cont,'File',4,1)
	      call smg$put_chars(dis_cont,'Key' ,5,1)
	      minl = 6
	      if(link_rec.key_nr .ge. 0) then
	        call smg$put_chars(dis_cont,'Match',minl,1)
	        minl = minl + 1
	      endif
	      if(draw_if) then
	        call smg$put_chars(dis_cont,'If',minl,1)
	        minl = minl + 1
	      endif
	      if(draw_compute) then
	        call smg$put_chars(dis_cont,'Compute',minl,1)
	        minl = minl + 1
	      endif
	    endif
	    call smg$draw_line(dis_cont,1,infolen,min(minl,lent),infolen)
	  end if
c
	  if(des_rec.ent_type .eq. enttyp_user) then
	    p_des_rec_fil = des_rec.link_back
	    line = des_rec_fil.username
	    nk = dix_util_get_len_fu(line)
	  else
	    call dix_util_get_type_name(des_rec.ent_type,line,nk,nb1)
	  endif
	  if(nk .eq. 0) then
	    line = 'Unknown'
	    nk = 7
	  endif
	  nk = nk+1
	  line(nk:nk) = '*'
	  nb1 = (des_rec.flags .and. des_flag_nb_reserved_mask)
c
	  if((des_rec.flags .and. des_flag_is_variable) .ne. 0) then
	    line(nk:nk+2) = '(*)'
	    nk = nk + 3
	  else
	    k1 = (des_rec.size-nb1*bits_per_byte)/bits_per_byte
	    k2 = mod(des_rec.size-nb1*bits_per_byte,bits_per_byte)
	    if(k2 .eq. 0) then
	      call sys$fao('!UL',nk1,line(nk+1:),%val(k1))
	    else
	      call sys$fao('!UL.!UL',nk1,line(nk+1:),%val(k1),%val(k2))
	    endif
	    nk = nk + nk1
	    conmask = des_rec.flags .and. des_flag_translate_mask
	    if(conmask   .ne. des_flag_translate_nor) then
	      if(conmask .eq. des_flag_translate_hex) kar = 'H'
	      if(conmask .eq. des_flag_translate_oct) kar = 'O'
	      if(conmask .eq. des_flag_translate_bin) kar = 'B'
	      line(nk+1:nk+2) = '/'//kar
	      nk = nk + 2
	    endif
	    conmask = des_rec.flags .and. des_flag_case_mask
            if(conmask   .ne. des_flag_case_no_case) then
              if(conmask .eq. des_flag_case_upper) line(nk+1:) = '/UP'
              if(conmask .eq. des_flag_case_lower) line(nk+1:) = '/LO'
              nk = nk + 3
            endif
	  end if
c
	  if(des_rec.ent_type .eq. enttyp_user) then
	    line(nk+1:) = '/USER'
	    nk = nk + 5
	  endif
c
	  needed_wid = max(needed_wid,nk)
	  idx_line = 1
	  if(k .eq. 2)call smg$put_chars(dis_cont,line(1:nk),
     1               idx_line,infolen+1,smg$m_erase_to_eol)
	  if(dis_cont .eq. 0) then
	   if(.not. dix_dump_print_line(control,indent,
     1                 'Type      :'//line(1:nk))) goto 90
	  endif
	  idx_line = idx_line + 1
c
	  line = dix_util_tfas(des_rec.flags .and. des_flag_is_variable)
	  needed_wid = max(needed_wid,5)
	  if(k .eq. 2) call smg$put_chars(dis_cont,line(1:5),
     1                      idx_line,infolen+1)
	  if(dis_cont .eq. 0) then
	    if(.not. dix_dump_print_line(control,indent,
     1                 'Variable  :'//line(1:5))) goto 90
	  endif
	  idx_line = idx_line + 1
c
	  line = dix_util_tfas((des_rec.flags .and. des_flag_has_dependancy))
	  needed_wid = max(needed_wid,5)
	  if(k .eq. 2) call smg$put_chars(dis_cont,line(1:5),
     1                idx_line,infolen+1)
	  if(dis_cont .eq. 0) then
	    if(.not. dix_dump_print_line(control,indent,
     1                 'Dependency:'//line(1:5))) goto 90
	  endif
	  idx_line = idx_line + 1
c
c Check on link record to other file
c
	  if(des_rec.p_link_rec .ne. 0) then
c
	    needed_len = needed_len + 1
	    p_link_rec = des_rec.p_link_rec
	    nk =   link_rec.nk_link_file
	    line = link_rec.link_file
	    needed_wid = max(needed_wid,nk)
	    if(k .eq. 2) call smg$put_chars(dis_cont,line(1:nk),
     1                idx_line,infolen+1)
	    if(dis_cont .eq. 0) then
	      if(.not. dix_dump_print_line(control,indent,
     1                 'Link file :'//line(1:nk))) goto 90
	    endif
	    draw_file = .true.
	    idx_line = idx_line + 1
c
	    if(link_rec.key_nr .lt. 0) then
	      line = 'Record'
	      nk = 6
	    else
	      nk = 0
	      call sys$fao('!UL',nk,line,%val(link_rec.key_nr))
	    endif
	    needed_wid = max(needed_wid,nk)
	    needed_len = needed_len + 1
	    if(k .eq. 2) call smg$put_chars(dis_cont,line(1:nk),
     1                idx_line,infolen+1)
	    if(dis_cont .eq. 0) then
	      if(.not. dix_dump_print_line(control,indent,
     1                 'Link field:'//line(1:nk))) goto 90
	    endif
	    idx_line = idx_line + 1
c
	    if(link_rec.key_nr .ge. 0) then
	      call str$element(line,link_rec.match+2,',','LT,LE,EQ,GE,GT')
	      nk = 2
	      needed_wid = max(needed_wid,nk)
	      needed_len = needed_len + 1
	      if(k .eq. 2) call smg$put_chars(dis_cont,line(1:nk),
     1                idx_line,infolen+1)
	      if(dis_cont .eq. 0) then
	        if(.not. dix_dump_print_line(control,indent,
     1                 'Match     :'//line(1:nk))) goto 90
	      endif
	      idx_line = idx_line + 1
	    endif
c
	    if(link_rec.if_line.dsc$w_maxstrlen .ne. 0) then
	      draw_if = .true.
	      call dix_util_copy_string(link_rec.if_line,line)
	      nk   = dix_util_get_len_fu(line)
	      needed_wid = max(needed_wid,nk)
	      needed_len = needed_len + 1
	      if(k .eq. 2) call smg$put_chars(dis_cont,line(1:nk),
     1                idx_line,infolen+1)
	      if(dis_cont .eq. 0) then
	        if(.not. dix_dump_print_line(control,indent,
     1                 'If        :'//line)) goto 90
	      endif
	      idx_line = idx_line + 1
	    endif
c
	    if(link_rec.comp_line.dsc$w_maxstrlen .ne. 0) then
	      draw_compute = .true.
	      call dix_util_copy_string(link_rec.comp_line,line)
	      nk   = dix_util_get_len_fu(line)
	      needed_wid = max(needed_wid,nk)
	      needed_len = needed_len + 1
	      if(k .eq. 2) call smg$put_chars(dis_cont,line(1:nk),
     1                idx_line,infolen+1)
	      if(dis_cont .eq. 0) then
	        if(.not. dix_dump_print_line(control,indent,
     1                 'Computinfo:'//line(1:nk))) goto 90
	      endif
	      idx_line = idx_line + 1
	    endif
	  endif
c
	  if((des_rec.flags .and. des_flag_is_variable) .ne. 0 .or. 
     1        nb1 .ne. 0) then
	    needed_len = needed_len + 1
	    if(nb1 .gt. 0) then
	      call sys$fao('!UL',nk,line,%val(des_rec.act_size/bits_per_byte))
	    else
	      call sys$fao('!UL',nk,line,%val(des_rec.size/bits_per_byte))
	    endif
	    needed_wid = max(needed_wid,nk)
	    if(k .eq. 2) then
	      call smg$put_chars(dis_cont,'Cur_size',idx_line,1)
	      call smg$put_chars(dis_cont,line(1:nk),idx_line,infolen+1,
     1                        smg$m_erase_to_eol)
	    end if
	    if(dis_cont .eq. 0) then
	      if(.not. dix_dump_print_line(control,indent,
     1                 'Cur_size  :'//line(1:nk))) goto 90
	    endif
	    idx_line = idx_line + 1
	  end if
c
	  if(des_rec.min_val .ne. des_rec.max_val) then
	    needed_len = needed_len + 1
	    call sys$fao('!UL-!UL',nk,line,%val(des_rec.min_val),
     1                %val(des_rec.max_val))
	    needed_wid = max(needed_wid,nk)
	    if(k .eq. 2) then
	      call smg$put_chars(dis_cont,'Range',idx_line,1)
	      call smg$put_chars(dis_cont,line(1:nk),idx_line,infolen+1,
     1                        smg$m_erase_to_eol)
	    end if
	    if(dis_cont .eq. 0) then
	      if(.not. dix_dump_print_line(control,indent,
     1                 'Range     :'//line(1:nk))) goto 90
	    endif
	    idx_line = idx_line + 1
	  endif
c
	  if(des_rec.fldnam.dsc$w_maxstrlen .ne. 0) then
	    nk    = max(needed_wid+infolen,40)	!width in this case
	    maxl  = control.nrows-idx_line-1		!max length in this case
	    if(dis_cont .eq. 0) then
	      if(.not. dix_dump_print_line(control,indent,'Fields    :')) 
     1                  goto 90
	      if(.not. dix_dump_print_line(control,indent+4,
     1                  des_rec.fldnam)) goto 90
	    endif
	    if(des_rec.fldnam.dsc$w_maxstrlen .le. nk) then
	      one_line = .true.
	      needed_len = needed_len + 1
	      needed_wid = max(needed_wid,des_rec.fldnam.dsc$w_maxstrlen)
	    else
	      one_line = .false.
c
c Takes more than one line, compute how many extra
c
	      needed_wid = nk-infolen
	      nlext = min(maxl,(des_rec.fldnam.dsc$w_maxstrlen+nk-1)/nk)
	      needed_len = needed_len + nlext
	    end if
	    if(k .eq. 2) then
	      if(one_line) then
	        call smg$put_chars(dis_cont,'Values',idx_line,1)
	        call smg$put_chars(dis_cont,des_rec.fldnam,
     1                idx_line,infolen+1,smg$m_erase_to_eol)
	      else
	        call smg$draw_line(dis_cont,idx_line,1,idx_line,wid)
	        call smg$put_chars(dis_cont,'Values',idx_line,(wid-6)/2)
	        fld_des = des_rec.fldnam
	        do l=1,nlext	        
	          fld_des.dsc$w_maxstrlen =
     1                min(nk,des_rec.fldnam.dsc$w_maxstrlen-(l-1)*nk)
	          call smg$put_chars(dis_cont,fld_des,idx_line+l,1,
     1                        smg$m_erase_to_eol)
	          fld_des.dsc$a_pointer = fld_des.dsc$a_pointer + nk
	        enddo
	      endif
	    end if
	  end if 
	end do
c
	display_des = .true.
90	return
	end
c
	subroutine dix_dump_get_key(control,dis_id,dis_id_offset,screen,
     1                              max_pos,iterm,dis,
     1                              offset_in,file,
     1                              des_mode,has_fields,
     1                              krow,kcol,context,whole_line)
	implicit none
c
c Return a key from the user
c
	include 'dix_def.inc'
	include 'dix_screen_def.inc'
	record /control/ control
	integer*4 dis_id		!:i: data display id
	integer*4 dis_id_offset		!:i: display id for offset (or 0)
	record /screen_data/ screen		!:io: screen data
	integer*4 max_pos		!:i: length of last itm in rows
	integer*4 iterm			!:o: terminatoir (typed key)
	record /dis_pars/  dis		!:i: display parameters
	integer*4 offset_in		!:i: current byte offset in data record
	record /file_info/ file		!:i: file information
	logical*4 des_mode		!:i: des/raw mode
	logical*4 has_fields		!:i: does description contain bitfields
	integer*4 krow			!:o: the row for the mouse click
	integer*4 kcol			!:o: the col for the mouse click
	character*(*) context		!:i: the screen context
	logical*4 whole_line		!:i: allow the cursor in the whole screen
c#
	integer*4 k,offset,limit,jstat,kstat,did,col_bold,row_bold
	integer*4 col_bold1,row_bold1
c
c Check if top line in screen
c
	include '($smgdef)'
c
	logical*4 dix_smg_find_string1
	logical*4 dix_dump_in_modify
	logical*4 dix_smg_question
	logical*4 dix_smg_get_int
c
	external dix_msg_notindes
	external dix_msg_notinraw
	external dix_msg_recempty
	external dix_msg_notindex
	external dix_msg_fixfile
	external dix_msg_notfixfile
	external dix_msg_notrelidx
	external dix_msg_seanotf
c
	integer*4 max_smooth_scroll
	parameter (max_smooth_scroll=20)
c
c Start of coding
c
	offset = offset_in
	k = 0
c
	call dix_dump_screen_dis_count(offset_in,dis.number_hex,
     1               control.dis_kop,2,20,has_fields,8,control)
c
c Make sure position is in the screen
c
	if(des_mode) then
	  call dix_smg_set_scroll(dis_id,dis_id_offset,screen,0,1)
	else
	  call dix_smg_set_scroll(dis_id,dis_id_offset,screen,0,0)
	endif
c
c Make sure bottom line is in screen, 
c
	if(whole_line) then
	  limit = screen.view_ncols
	else
	  limit = 1
	endif
	do while(screen.col-screen.col_offset .ge. limit)
	  if(screen.col-screen.col_offset-max_pos .lt. max_smooth_scroll) then
	    k = 1
	  else
	    k = screen.col-screen.col_offset-max_pos
	  end if
	  screen.col_offset = screen.col_offset+k
	  call smg$scroll_viewport(dis_id,smg$m_left,k)
	end do
	goto 10
c
c Some error messages
c
7	call dix_message(control,dix_msg_recempty)
	goto 10
c
c Illegal command for this mode
c
8	if(des_mode) then
	  call dix_message(control,dix_msg_notindes)
	else
	  call dix_message(control,dix_msg_notinraw)
	end if
c
c Set cursor, read key
c
10	call smg$set_cursor_abs(dis_id,screen.row,screen.col)
	call dix_get_key(control,iterm,krow,kcol,context)
c
	if(control.bold_set .ne. 0) then
	  call smg$change_rendition(control.bold_set,
     1           control.row_bold,iabs(control.col_bold),
     1                              1,control.nk_sear,0)
	  control.bold_set = 0
	end if
c
c Split out commands
c
	if(iterm .eq. key_byte) then
	  if(des_mode) goto 8
	elseif(iterm .eq. key_contdis) then
	  if(.not. des_mode) goto 8
	elseif(iterm .eq. key_fileinfo) then
	  call dix_smg_file_info_scr(control,file)
	  goto 10
	elseif(iterm .eq. key_getfields) then
	  if(.not. des_mode) goto 8
	elseif(iterm .eq. key_display_decimal) then
	  dis.hex = des_flag_translate_nor
	elseif(iterm .eq. key_display_octal) then
	  dis.hex = des_flag_translate_oct
	elseif(iterm .eq. key_display_binary) then
	  dis.hex = des_flag_translate_bin
	elseif(iterm .eq. key_display_hex) then
	  dis.hex = des_flag_translate_hex
	elseif(iterm .eq. key_hexdeco) then
	  dis.number_hex = .not. dis.number_hex
	elseif(iterm .eq. key_put) then
	  if(.not. dix_dump_in_modify(control,file.modify,.false.)) goto 10
	  if(.not. file.indexed) then
	    call dix_message(control,dix_msg_notindex)
	    goto 10
	  end if
	elseif(iterm .eq. key_long) then
	  if(des_mode) goto 8
	elseif(iterm .eq. key_print) then
	  call dix_dump_screen_print(control,dis_id,screen.nlines,file)
	  goto 10
	elseif(iterm .eq. key_remove) then
	  if(.not. dix_dump_in_modify(control,file.modify,.false.)) goto 10
	  if(.not. (file.indexed .or. file.relative)) then
	    call dix_message(control,dix_msg_notrelidx)
	    goto 10
	  end if
	  if(.not. dix_smg_question(control,
     1      'Deleting record; Are you sure',.false.)) goto 10
	elseif(iterm .eq. key_newreclen) then
	  if(.not. dix_dump_in_modify(control,file.modify,.false.)) goto 10
	  if(file.fixed) then
	    call dix_message(control,dix_msg_fixfile)
	  else
	    if(.not. file.indexed) then
	      call dix_message(control,dix_msg_notindex)
	    else
	      k = offset
	      if(dix_smg_get_int(control,'recordlength',k,
     1                     file.minrecl,file.maxrecl)) then
	        file.data.nb_data = k
	      end if
	    end if
	  end if
	elseif(iterm .eq. key_viewdesc) then
	  if(.not. des_mode) goto 8
	elseif(iterm .eq. key_viewdes) then
	  if(.not. des_mode) goto 8
	elseif(iterm .eq. key_word) then
	  if(des_mode) goto 8
	elseif(iterm .eq. key_page) then
	  if(control.forward) then
	    iterm = key_next
	  else
	    iterm = key_prev
	  end if
	elseif(iterm .eq. key_set_forw) then
	  control.forward = .true.
	  goto 10
	elseif(iterm .eq. key_set_backw) then
	  control.forward = .false.
	  goto 10
	elseif(iterm .eq. key_find .or. iterm .eq. key_find1) then
	  if(screen.nlines .eq. 0) goto 7
	  if(iterm .eq. key_find1) control.nk_Sear = 0
	  row_bold  = screen.row
	  col_bold  = iabs(control.col_bold)
	  row_bold1 = screen.row
	  col_bold1 = iabs(control.col_bold)
	  if(control.nk_sear .eq. 0) then
c
c Get the search string
c
	    call dix_smg_get_sear_string(control,
     1            control.sear,control.nk_sear,
     1            control.forward)
	    if(control.nk_sear .eq. 0) goto 10
	  endif
c
c Now we must search in two displays
c  1. the offset display (if present)
c  2. the data display
c  if forward the first search 1, and then 2, 
c  if backward search 2 and then 1
c
	  if(dis_id_offset .ne. 0) then
c
	    jstat = dix_smg_find_string1(dis_id,
     1               control.nk_sear,control.sear,
     1               row_bold,col_bold,
     1               screen.nlines,control.forward)
	    kstat = dix_smg_find_string1(dis_id_offset,
     1               control.nk_sear,control.sear,
     1               row_bold1,col_bold1,
     1               screen.nlines,control.forward)
	    if(jstat) then
c
c Found in dis_id, see if also in dis_id_offset
c
	      if(kstat) then
c
c Now we found if in both displays, get the lowest value
c
	        if(control.forward) then
	          if(row_bold* 32268+col_bold .le.
     1               row_bold1*32268+col_bold1) then
c
c closest in dis_id
c
	            did = dis_id
	          else
	            did = dis_id_offset
	            col_bold = -col_bold1
	            row_bold = row_bold1
	          endif
	        else
	          if(row_bold* 32768+col_bold .le.
     1               row_bold1*32768+col_bold1) then
c
c Closest in dis_id_offset
c
	            did = dis_id_offset
	            col_bold = -col_bold1
	            row_bold = row_bold1
	          else
	            did = dis_id
	          endif
	        endif	   
	      else
c
c Only in dis_id, 
c
	        did = dis_id	!twas in this display
	      endif
	    else
c
c Not found in dis_id, see if found in dis_id_offset
c
	      if(kstat) then
c
c Yes found in dis_id_offset
c
	        did = dis_id_offset	!
	        col_bold = -col_bold1	!remember in dis_id_offset
	        row_bold =  row_bold1
	        jstat = 1           	!and tell we found it
	      endif
	    endif
	  else
	    did = dis_id
	    jstat = dix_smg_find_string1(dis_id,
     1               control.nk_sear,control.sear,
     1               row_bold,col_bold,
     1               screen.nlines,control.forward)
	  endif
	  if(jstat) then
	    control.bold_set = did
	    control.row_bold = row_bold
	    control.col_bold = col_bold
	    screen.row = control.row_bold
	    screen.col = control.col_bold
	    call smg$change_rendition(control.bold_set,control.row_bold,
     1             iabs(control.col_bold),1,control.nk_sear,smg$m_bold)
	  else
	    call dix_message(control,dix_msg_seanotf)
	    goto 10
	  end if
	  iterm = key_find
	elseif(iterm .eq. key_next_window .or.
     1         iterm .eq. key_prev_window) then
	  if(des_mode) goto 8
	elseif(iterm .eq. key_swap_num) then
	  dis.number = .not. dis.number
	elseif(iterm .eq. key_help) then
	  call dix_smg_help(control,context)
	  goto 10
	elseif(iterm .eq. key_contdis) then
	  if(.not. des_mode) goto 8
	elseif(iterm .eq. key_do) then
	  if(.not. dix_dump_in_modify(control,file.modify,.false.)) goto 10
	end if
90	return
	end

	function dix_dump_in_modify(control,mod,readonly_field) 
	implicit none
c
c Check if in /mod mode, if not give message
c
	include 'dix_def.inc'
	record /control/ control
	logical*4 mod 			!:i: modify mode??
	logical*4 readonly_field	!:i: is this field readonly
	logical*4 dix_dump_in_modify	!:f: true if in modify mode
c#
	external dix_msg_notinmod
	external dix_msg_readonly
c
	dix_dump_in_modify = mod
	if(.not. mod)then
	  call dix_message(control,dix_msg_notinmod)
	else
	  if(readonly_field) then
	    call dix_message(control,dix_msg_readonly)
	    dix_dump_in_modify = .false.
	  endif
	endif
	return
	end 		

	subroutine dix_dump_screen_raw(control,iterm,dis,file,in_vfc,context)
	implicit none
c
c Dump record in raw mode
c
	include 'dix_def.inc'
	include 'dix_screen_def.inc'
c
	record /control/ control
	integer*4 iterm			!:o: terminator
	record /dis_pars/ dis		!:i: display parameters
	logical*4 in_vfc
	character*(*) context		!:i: contexy (screen) name
	record /file_info/ file		!:i: file information
c#
	include '($smgdef)'
c
	integer*4 page_size,k,stat,krow,kcol,nk,dis_id_bar
	integer*4 l,posasc,nkar,kpl,fldsiz,nbit
	logical*4 modified,field_offset
c
	character*(max_screen_width) line
c
	record /des_rec/ des_rec
c
	logical*4 ascdis
	logical*4 dix_dump_in_modify
	integer*4 dix_util_hex_kar
	external dix_msg_nodata
	external dix_msg_novfc
	external dix_msg_illhexchar
	external dix_msg_illbinchar
	external dix_msg_illoctchar
	external dix_msg_illval
	external dix_msg_recempty
c
c
c
	record /display_data_raw/ disp_dat
	record /display_data_raw/ disp_vfc
	record /display_data_raw/ disp
	pointer (p_disp,disp)
c
c local vars
c
	logical*4 dix_con_ascint
c
c start, display 16 values on 1 line
c
	disp_dat.magic = magic_display_data_raw
	disp_vfc.magic = magic_display_data_raw
c
	ascdis        = .false.
	disp_dat.indx = 0
	disp_vfc.indx = 0
c
c
5	if(dis.hex .eq. des_flag_translate_hex) then
	  line = 'Hex'
	elseif(dis.hex .eq. des_flag_translate_oct) then
	  line = 'Oct'
	elseif(dis.hex .eq. des_flag_translate_bin) then
	  line = 'Bin'
	else
	  if(dis.unsigned) then
	    line = 'Unsign'
	  else
	    line = 'Signed'
	  endif
	endif
	call smg$put_chars(control.dis_kop,line(1:6),2,34,,
     1                 smg$m_bold .or. smg$m_reverse)
c
	call dix_dump_vars(control,dis,kpl,fldsiz,posasc)
c
	disp_dat.screen.nlines     = (file.data.nb_data+kpl-1)/kpl 
	disp_dat.screen.disp_nrows = disp_dat.screen.nlines
	disp_dat.screen.disp_ncols = control.ncols
	disp_dat.screen.ncols      = disp_dat.screen.disp_ncols
c
	call smg$create_virtual_display(disp_dat.screen.disp_nrows,
     1           disp_dat.screen.disp_ncols,disp_dat.dis_id)
c
	disp_dat.screen.col_offset = 1
	disp_dat.screen.row_offset = 1
	disp_dat.screen.paste_row = 4
	disp_dat.screen.paste_col = 1
	disp_dat.screen.view_nrows = control.nrows-disp_dat.screen.paste_row+1
	disp_dat.screen.view_ncols = disp_dat.screen.ncols-
     1                               disp_dat.screen.paste_col+1
c
c Update the 2nd line (recsiz,recnr, and RFA)
c 
	call dix_dump_screen_display_hdr_2(control,file,dis)
C
	do k=1,disp_dat.screen.nlines
	  call dix_dump_screen_raw_line(control,disp_dat.dis_id,k,kpl,file,
     1                    dis,posasc,fldsiz,.false.,0)
	end do
c
c Create the header line, kpl can be 8,16 or 32 depending on the screen width
c  and the data format
c
	call dix_dump_create_header3(line,nk,kpl,fldsiz,dis,posasc)
	call smg$put_chars(control.dis_kop,line(1:control.ncols),3,1,,
     1              smg$m_reverse)
c
	page_size  = disp_dat.screen.view_nrows-2
c
	if(file.data.nb_vfc .gt. 0) then
c
c There is vfc data, reserve 2 lines for the vfc display
c
	  disp_dat.screen.view_nrows = disp_dat.screen.view_nrows - 2
c
c And create the vfc display (only one line)
c
	  call dix_dump_vars(control,dis,kpl,fldsiz,posasc)
c
	  disp_vfc.screen.nlines     = (file.data.nb_vfc+kpl-1)/kpl 
	  disp_vfc.screen.disp_nrows = disp_vfc.screen.nlines
	  disp_vfc.screen.disp_ncols = control.ncols
	  disp_vfc.screen.view_nrows = 1
	  disp_vfc.screen.view_ncols = control.ncols
	  disp_vfc.screen.ncols      = disp_vfc.screen.view_ncols
	  disp_vfc.screen.paste_row  = control.nrows
	  disp_vfc.screen.paste_col  = 1
c
	  call smg$create_virtual_display(disp_vfc.screen.disp_nrows,
     1                                    disp_vfc.screen.disp_ncols,
     1                                    disp_vfc.dis_id)
c
	  call smg$create_viewport(disp_vfc.dis_id,
     1                             disp_vfc.screen.row_offset,
     1                             disp_vfc.screen.col_offset,
     1                             disp_vfc.screen.view_nrows,
     1                             disp_vfc.screen.view_ncols)
	  call smg$paste_virtual_display(disp_vfc.dis_id,control.paste_id,
     1                     disp_vfc.screen.paste_row,
     1                     disp_vfc.screen.paste_col)
c
	  do k=1,disp_vfc.screen.nlines
	    call dix_dump_screen_raw_line(control,disp_vfc.dis_id,k,kpl,file,
     1                    dis,posasc,fldsiz,.true.,0)
	  end do
c
c And create a bar display with a line in it
c
	  call smg$create_virtual_display(1,control.ncols,dis_id_bar)
	  call smg$paste_virtual_display(dis_id_bar,control.paste_id,
     1                     disp_vfc.screen.paste_row-1,1)
c
c Draw a separating line
c
	  call smg$draw_line(dis_id_bar,1,1,1,control.ncols)
	  call smg$put_chars(dis_id_bar,'VFC Data',1,10)
	else
	  disp_vfc.dis_id = 0
	endif
c
c Now create viewport
c
	call smg$create_viewport(disp_dat.dis_id,
     1                           disp_dat.screen.row_offset,
     1                           disp_dat.screen.col_offset,
     1                           disp_dat.screen.view_nrows,
     1                           disp_dat.screen.view_ncols)
c
	call smg$paste_virtual_display(disp_dat.dis_id,control.paste_id,
     1                     disp_dat.screen.paste_row,
     1                     disp_dat.screen.paste_col)
c
	dis.compres = .false.
	if(file.data.nb_data .eq. 0) then
	  call dix_message(control,dix_msg_nodata)
	end if
c
	if(in_vfc) then
	  p_disp = %loc(disp_vfc)
	else
	  p_disp = %loc(disp_dat)
	end if
c
c
10	if(in_vfc) then
	  disp.indx = min(file.data.nb_vfc*bits_per_byte-1,disp.indx)
	else
	  disp.indx = min(file.data.nb_data*bits_per_byte-1,disp.indx)
	endif
	disp.indx = max(0,disp.indx)
c
c index is bit offset, round of to display size
c
	if(dis.hex .eq. des_flag_translate_hex) then
c
c Hex display, round to nibble
c
	  disp.indx = 4*(disp.indx/4)	!round to 4 fold
	elseif(dis.hex .eq. des_flag_translate_nor) then
c
c Decimal, round to wordsize
c	  
	  disp.indx = dis.word*bits_per_byte*
     1     (disp.indx/(dis.word*bits_per_byte))	!round to 8*wordsize
	elseif(dis.hex .eq. des_flag_translate_oct) then
c
c ROund up to the word, and then the bit-offset must be a multiple of 3
c
	  k = dis.word*bits_per_byte*(disp.indx/(dis.word*bits_per_byte))
	  l = disp.indx-k	!bit offset in word
	  l = 3*(l/3)		!round to 3bits
	  disp.indx = k + l	!and add again
	endif
c
c
c Set the right screen coordinates in disp
c
	call dix_dump_get_coord(disp.indx,ascdis,
     1                             dis,kpl,posasc,fldsiz,
     1                             disp.screen.row,disp.screen.col)
c
	field_offset = (dis.hex .ne. des_flag_translate_nor)

	call dix_dump_get_key(control,disp.dis_id,0,disp.screen,
     1            disp.screen.view_nrows-1,
     1            iterm,dis,disp.indx,file,
     1            .false.,field_offset,
     1            krow,kcol,context,.true.)
c
c Set cursor
c
	if(iterm .eq. key_mouse_left) then
c
c LEft mouse click, set the cursor
c
	  call dix_smg_set_ptr_raw(control,krow,kcol,posasc,ascdis,
     1                                kpl,dis,fldsiz,in_vfc,
     1                                disp_dat,disp_vfc,p_disp)
c
	  call dix_dump_get_coord(disp.indx,ascdis,
     1                               dis,kpl,posasc,fldsiz,
     1                             disp.screen.row,disp.screen.col)
	  goto 10
	elseif(iterm .eq. key_mouse_middle) then
c
c Used for scrolling, if in the lower half of the 
c  display, the display is scrolled down (if possible)
c  if in the upper half, the display is scrolled upward
c
	  krow = krow - 3
	  if(krow .lt. disp.screen.view_nrows/2) then
	    disp.indx = disp.indx - page_size*kpl*bits_per_byte
	  else
	    disp.indx = disp.indx + page_size*kpl*bits_per_byte
	  endif
	  goto 10
	elseif(iterm .eq. key_mouse_right .or. iterm .eq. key_menu) then
c
	  call dix_smg_set_ptr_raw(control,krow,kcol,posasc,ascdis,
     1                                kpl,dis,fldsiz,in_vfc,
     1                                disp_dat,disp_vfc,p_disp)
	  call dix_dump_get_coord(disp.indx,ascdis,
     1                               dis,kpl,posasc,fldsiz,
     1                             disp.screen.row,disp.screen.col)
	  nk = 0
	  call dix_append(nk,line,'Top,Bot,Long,'//
     1              'Word,Byte,Hex,Decimal,Desmode')
	  if(dis.hex .ne. des_flag_translate_nor) then
	    call dix_append(nk,line,',Decimal data')	  
	  endif
	  if(dis.hex .ne. des_flag_translate_oct) then
	    call dix_append(nk,line,',Octal data')	  
	  endif
	  if(dis.hex .ne. des_flag_translate_bin) then
	    call dix_append(nk,line,',binary data')	  
	  endif
	  if(dis.hex .ne. des_flag_translate_hex) then
	    call dix_append(nk,line,',Hex data')	  
	  endif
	  if(dis.number_hex) then
	    call dix_append(nk,line,',Decimal offset')	  
	  else
	    call dix_append(nk,line,',Hex offset')	  
	  endif
c
c Display is pasted at row 4
c
	  call dix_smg_select_menu(control,line(1:nk),line,
     1               .false.,'Choises',disp.screen.row+3,
     1                disp.screen.col,.true.)
c
	  if(    line(1:2) .eq. 'BO') then
	    iterm = key_bot
	  elseif(line(1:2) .eq. 'BI') then
	    iterm = key_display_binary
	  elseif(line(1:2) .eq. 'BY') then
	    iterm = key_byte
	  elseif(line(1:1) .eq. 'C') then
	    iterm = key_compres
	  elseif(line(1:3) .eq. 'DES') then
	    iterm = key_swap_dis
	  elseif(line(1:3) .eq. 'DEC') then
	    if(index(line,'OFFSET') .ne. 0) iterm = key_hexdeco
	    if(index(line,'DATA') .ne. 0) iterm = key_display_decimal
	  elseif(line(1:3) .eq. 'HEX') then
	    if(index(line,'OFFSET') .ne. 0) iterm = key_hexdeco
	    if(index(line,'DATA') .ne. 0)   iterm = key_display_hex
	  elseif(line(1:1) .eq. 'L') then
	    iterm = key_long
	  elseif(line(1:1) .eq. 'O') then
	    iterm = key_display_octal
	  elseif(line(1:1) .eq. 'T') then
	    iterm = key_top
	  elseif(line(1:1) .eq. 'V') then
	    iterm = key_viewvfc
	  elseif(line(1:1) .eq. 'W') then
	    iterm = key_word
	  else
c
c Ignore 
c
	    goto 10
	  endif	  
	endif
	if(iterm .eq. key_prev) then
	  disp.indx = disp.indx - page_size*kpl*bits_per_byte
	elseif(iterm .eq. key_next) then
	  disp.indx = disp.indx + page_size*kpl*bits_per_byte
	elseif(iterm .eq. key_left) then
	  if(ascdis) then
c
c In ascii mode  left arrow means decrease bit_offset
c in binary mode left arrow means increase bit_offset
c
	    k = -bits_per_byte
	  else
	    if(dis.hex .eq. des_flag_translate_hex) then
	      k = 4
	    elseif(dis.hex .eq. des_flag_translate_bin) then
	      k = 1
	    elseif(dis.hex .eq. des_flag_translate_oct) then
c
c THis is a bit more elaborate. Normally we skip 3 bits, but
c  because the byte size(8,16,32) is not a multiple of 3, we must 
c  take care of the upper char this is 2(8bits), 1(16 nbits) or 2(32 bits)
c  bits in size
c
	      k = 3
c
c See if we are on the lowest bit of a byte/word/longword
c
	      l = mod(disp.indx,dis.word*bits_per_byte)
	      if(l+3 .gt. dis.word*bits_per_byte) then
	        k = dis.word*bits_per_byte - l
	      endif
	    else
	      k = dis.word*bits_per_byte
	    endif
	  endif
	  disp.indx = disp.indx+k
	elseif(iterm .eq. key_right) then
c
c In ascii mode  right arrow means increase bit_offset
c in binary mode right arrow means decrease bit_offset
c
	  if(ascdis) then
	    k = bits_per_byte
	  else
	    if(dis.hex .eq. des_flag_translate_hex) then
	      k = 4
	    elseif(dis.hex .eq. des_flag_translate_bin) then
	      k = 1
	    elseif(dis.hex .eq. des_flag_translate_oct) then
c
c THis is a bit more elaborate. Normally we skip 3 bits, but
c  because the byte size(8,16,32) is not a multiple of 3, we must 
c  take care of the upper char this is 2(8bits), 1(16 nbits) or 2(32 bits)
c  bits in size
c
	      k = 3
c
c See oif we are on the lowest bit of a byte/word/longword
c
	      if(mod(disp.indx,dis.word*bits_per_byte) .eq. 0) then
c
c Yes we are, not we must skip less bits
c
	        k = mod(dis.word*bits_per_byte,3)
	      endif
	    else
	      k = dis.word*bits_per_byte
	    endif
c
c Reverse the direction
c
	    k = -k
	  endif
	  disp.indx = disp.indx+k
	elseif(iterm .eq. key_bot) then
	  if(in_vfc) then
	    disp.indx = file.data.nb_vfc*bits_per_byte-1
	  else
	    disp.indx = file.data.nb_data*bits_per_byte-1
	  endif
	elseif(iterm .eq. key_compres) then
	  dis.unsigned = .not. dis.unsigned
	  goto 90			!let redisplay
	elseif(iterm .eq. key_dispall) then
	  if(file.data.nb_data .eq. 0) goto 79
	  call dix_dump_display_all(control,disp.indx,
     1                              file.data.data_rec,
     1                              file.data.nb_data,file,
     1                              modified,.true.,' ')
	  if(modified) iterm = key_chdis
	elseif(iterm .eq. key_viewvfc) then
	  if(file.data.nb_vfc .gt. 0) then
	    in_vfc = .not. in_vfc
	    if(in_vfc) then
	      p_disp = %loc(disp_vfc)
	    else
	      p_disp = %loc(disp_dat)
	    endif	     
	  else
	    call dix_message(control,dix_msg_novfc)
	  endif
	elseif(iterm .eq. key_top) then
	  disp.indx = 0
	elseif(iterm .eq. key_find) then
c
c Got position in buffer in disp.row
c
	  krow = disp.screen.row+disp.screen.paste_row-1
	  kcol = disp.screen.col+disp.screen.paste_col-1
	  call dix_smg_set_ptr_raw(control,krow,kcol,posasc,ascdis,
     1                                kpl,dis,fldsiz,in_vfc,
     1                                disp_dat,disp_vfc,p_disp)
	elseif(iterm .eq. key_up) then
	  disp.indx = disp.indx-kpl*bits_per_byte
	elseif(iterm .eq. key_down) then
	  disp.indx = disp.indx+kpl*bits_per_byte
	elseif(iterm .eq. key_next_window .or. 
     1         iterm .eq. key_prev_window) then
	  ascdis = .not. ascdis
	elseif(iterm .eq. key_save) then
	  call dix_smg_copy_save(control,file.data.nb_data,file.data.data_rec,
     1                           control.nb_save,control.save_area)
	elseif(iterm .eq. key_long) then
	  dis.word = 4
	  goto 90			!let redisplay
	elseif(iterm .eq. key_word) then
	  dis.word = 2
	  goto 90			!let redisplay
	elseif(iterm .eq. key_byte) then
	  dis.word = 1
	  goto 90			!let redisplay
	elseif(iterm .eq. key_display_hex) then
c
c RTound .indx off to 4 fold
c
	  dis.hex = des_flag_translate_hex
	  disp.indx = 4*(disp.indx/4)
	  goto 90	  
	elseif(iterm .eq. key_display_decimal) then
	  dis.hex = des_flag_translate_nor
c
c And round off to word size
c
	  k = dis.word*bits_per_byte
	  disp.indx = k*(disp.indx/k)
	  goto 90	  
	elseif(iterm .eq. key_display_octal) then
c
c And round off to word size
c
	  k = dis.word*bits_per_byte
	  disp.indx = k*(disp.indx/k)
	  dis.hex = des_flag_translate_oct
	  goto 90	  
	elseif(iterm .eq. key_display_binary) then
	  dis.hex = des_flag_translate_bin
	  goto 90	  
	elseif(iterm .eq. key_do) then
	  call dix_rms_update(control,file,.true.)
	elseif(iterm .le. key_chdis) then
	  goto 90
	else
c
c Character insert mode
c
	  if(iterm .lt. 0 .and. iterm .ne. key_enter) then
	    call dix_mes_invkey(control,context)
	  else
	    if(.not. dix_dump_in_modify(control,file.modify,.false.)) goto 10
	    if(ascdis) then
	      nbit = 8
	      if(in_vfc) then
	        call lib$insv(iterm,disp.indx,nbit,file.data.vfc_data)
	      else
	        call lib$insv(iterm,disp.indx,nbit,file.data.data_rec)
	      endif
	    else
c
c We get a character, for the hex/binary/octal mode we can insert the value
c directly, for integer we need to edit the string
c
	      if(dis.hex .ne. des_flag_translate_nor) then
c
c hex/binary/octal
c
	        if(dis.hex .eq. des_flag_translate_hex) then
	          nbit = 4
	          iterm = dix_util_hex_kar(iterm)
	          if(iterm .lt. 0) then
	            call dix_message(control,dix_msg_illhexchar)
	            goto 10
	          endif
	        elseif(dis.hex .eq. des_flag_translate_bin) then
	          nbit = 1
	          iterm = iterm - ichar('0')
	          if(iterm .lt. 0 .or. iterm .gt. 1) then
	            call dix_message(control,dix_msg_illbinchar)
	            goto 10
	          endif
	        elseif(dis.hex .eq. des_flag_translate_oct) then
c
c Now the octal part, normally 3 bits/byte, but in some cases only 1 or 2
c
	          nbit = 3
	          l = dis.word*bits_per_byte -
     1                mod(disp.indx,dis.word*bits_per_byte)
	          if(l .lt. 3) nbit = l
	          l = 2**nbit - 1	!compute limit
	          iterm = iterm - ichar('0')
	          if(iterm .gt.l) then
	            call dix_message(control,dix_msg_illoctchar,%val(l))
	            goto 10
	          endif
	        end if
c
c Now update buffer, we need to insert nbit bits at position .indx
c
	        if(in_vfc) then
	          call lib$insv(iterm,disp.indx,nbit,
     1                 file.data.vfc_data)
	        else
	          call lib$insv(iterm,disp.indx,nbit,
     1                 file.data.data_rec)
	        endif
c
	      else
c
c binary dump/decimal/octal, now let user type string
c
	        call dix_smg_get_string(control,disp.dis_id,
     1                       disp.screen.row,disp.screen.col,
     1                       fldsiz,line,0,iterm,nkar,.true.)
	        call dix_util_clear_descr(des_rec.fldnam,.false.)
	        des_rec.size    = dis.word*bits_per_byte
	        des_rec.bit_offset = disp.indx
	        des_rec.flags   = des_flag_translate_nor
	        if(dis.unsigned) then
	          des_rec.ent_type = enttyp_uint
	        else
	          des_rec.ent_type = enttyp_int
	        endif
	        if(in_vfc) then
	           stat = dix_con_ascint(line(1:nkar),file.data.vfc_data,
     1              des_rec,dis.hex,k,control)
	        else
	           stat = dix_con_ascint(line(1:nkar),file.data.data_rec,
     1              des_rec,dis.hex,k,control)	
	        endif
	        if(.not. stat) then
	          call dix_message(control,dix_msg_illval)
	        end if
	        nbit = des_rec.size
	      end if
	    end if
	    call dix_dump_screen_raw_line(control,disp.dis_id,
     1                    disp.screen.row,kpl,
     1                    file,dis,posasc,fldsiz,in_vfc,0)
	    disp.indx = disp.indx+nbit
	  end if
	endif
	goto 10
79	call dix_message(control,dix_msg_recempty)
	goto 10
90	if(iterm .eq. key_exit) then
	  if(file.data.nb_vfc .gt. 0) then
	    call smg$set_cursor_abs(disp_vfc.dis_id,
     1              disp_vfc.screen.disp_nrows,1)
	  else
	    call smg$set_cursor_abs(disp_dat.dis_id,
     1              disp_dat.screen.disp_nrows,1)
	  endif
	else
	  call smg$delete_virtual_display(disp_dat.dis_id)
	  if(file.data.nb_vfc .gt. 0) call smg$delete_virtual_display(
     1             disp_vfc.dis_id)
	endif
	if(iterm .gt. key_chmod) goto 5
	return
	end

	subroutine dix_dump_screen_print(control,dis_id,nlines,file)
	implicit none
c
	include 'dix_def.inc'
c
	record /control/control
	integer*4 dis_id		!:i: the display to be printed
	integer*4 nlines		!:i: this dispay contains # lines
	record /file_info/ file		!:i: file information
c#
	integer*4 lun,k,iterm,nkar,ipos,rmssts,rmsstv,ioerr,nk_f
	character*(max_screen_width) line
	character*(max_filename_length) fnam
	character*(max_short_line_length) stat,acce
c
	integer*4 dix_util_get_len_fu
	external dix_msg_filnotop
	external dix_msg_filecrea
	external dix_msg_fileappen
	external dix_msg_forterr
	external dix_msg_fileempty
c
	include '($smgdef)'
c
c Get a filename
c
	call dix_smg_get_str(control,'Filename',fnam,iterm)
	nk_f = dix_util_get_len_fu(fnam)
	if(iterm .eq. key_enter) then
	  if(nk_f .eq. 0) then
	    call dix_message(control,dix_msg_fileempty)
	    goto 90
	  endif
c
c If terminator = CR, than print
c
	  ipos = index(fnam(1:nk_f),'/')
	  stat = 'NEW'
	  acce = 'SEQUENTIAL'
	  if(ipos .gt. 0) then
	    line = fnam(ipos:nk_f)
	    fnam = fnam(1:ipos-1)
	    nk_f = ipos-1
	    call str$upcase(line,line)
	    if(index(line,'/A') .ne. 0) acce = 'APPEND'
	    stat = 'UNKNOWN'
	  end if	  
	  call lib$get_lun(lun)
	  open(lun,file=fnam(1:nk_f),status=stat,carriagecontrol='list',
     1           defaultfile='dix_screen.txt',
     1           access=acce,err=60)
	  write(lun,1034) file.fnam(1:file.nk_fnam)
1034	  format('Dump of record of file :',a)
c
c Print all lines
c
	  do k=1,nlines
	    call smg$read_from_display(dis_id,line,,k)
	    nkar = max(1,dix_util_get_len_fu(line))
	    write(lun,1100) line(1:nkar)
1100	    format(a)
	  end do
	  inquire(lun,name=line)
	  nkar = dix_util_get_len_fu(line)
	  close(lun)
	  if(stat(1:1) .eq. 'N') then
	    call dix_message(control,dix_msg_filecrea,line(1:nkar))
	  else
	    call dix_message(control,dix_msg_fileappen,line(1:nkar))
	  endif
	  goto 70
c
c Error in opening file, tell user
c
60	  call errsns(ioerr,rmssts,rmsstv)
	  call dix_message(control,dix_msg_filnotop,fnam(1:nk_f))
	  call cnv_forterr_message(ioerr,line)
	  nkar = dix_util_get_len_fu(line)
	  if(nkar .gt. 0) call dix_message(control,dix_msg_forterr,
     1                                     line(1:nkar))
	  if(rmssts .ne. 0) call dix_message(control,%val(rmssts))
	  if(rmssts .ne. 0) call dix_message(control,%val(rmsstv))
70	  call lib$free_lun(lun)
	end if
90	return
	end
	subroutine dix_smg_copy_save(control,nb_src,src,nb_dst,dst)
	implicit none
c
c Save current data to save area
c
	integer*4 control
	integer*4 nb_src
	byte src(*)
	integer*4 nb_dst
	byte dst(*)
c#
	external dix_msg_datasav
c
	call dix_util_copy(nb_src,src,dst)
	nb_dst = nb_src
	call dix_message(control,dix_msg_datasav,%val(nb_dst),
     1             %descr('PASTE_BUFFER'))
	return
	end
	subroutine dix_smg_copy_restore(control,nb_src,src,nb_dst,dst)
	implicit none
c
c Restore data from save area to current data area
c
	integer*4 control
	integer*4 nb_src
	byte src(*)
	integer*4 nb_dst
	byte dst(*)
c#
	external dix_msg_datarest
	external dix_msg_norest
c
	if(nb_src .gt. 0) then
	  call dix_util_copy(nb_src,src,dst)
	  nb_dst = nb_src
	  call dix_message(control,dix_msg_datarest,%val(nb_src),
     1            %descr('UNDO_AREA'))
	else
	  call dix_message(control,dix_msg_norest)
	end if
	return
	end
  	options /extend_source
	subroutine get_help_lines(control,help_des,raw_mode,
     1                            has_des,context)
	implicit none
c
c Since chars can be translated, the help is dynamaically build up
c done once on the first usage of dump_screen
c
	include 'dix_def.inc'
	record /control/ control	!:i: control block
	record /dyn_help/ help_des
	logical raw_mode		!:i: raw mode 
	logical*4 has_des		!:i: has descriptions
	character*(*) context		!:i: context (screen) name
c#
	call help_init(help_des,'dump screen',12,40)
c
c And go appending all helplines
c
	call help_topic(help_des,'Moves')
	call help_key(control,help_des,key_up,'1 line up',context)
	call help_key(control,help_des,key_down,'1 line down',context)
	call help_key(control,help_des,key_left,'1 pos to left',context)
	call help_key(control,help_des,key_right,'1 pos to right',context)
	if(.not. raw_mode) then
	  call help_key(control,help_des,key_first,'to first col',context)
	  call help_key(control,help_des,key_last,'to last col',context)
	endif
	call help_key(control,help_des,key_prev,'1 page up',context)
	call help_key(control,help_des,key_next,'1 page down',context)
	call help_key(control,help_des,key_top,'Top of data',context)
	call help_key(control,help_des,key_bot,'Bottom of data',context)
	call help_key(control,help_des,key_find,
     1             'Find string in record',context)
	call help_key(control,help_des,key_find1,
     1             'Ask string and find',context)
	call help_key(control,help_des,key_page,'Next or prev screen',context)
	call help_key(control,help_des,key_set_forw,'Set forward',context)
	call help_key(control,help_des,key_set_backw,'Set backward',context)
	if(raw_mode) then
	  call help_key(control,help_des,key_next_window,'Toggle bin/asc',context)
	endif
c
	call help_topic(help_des,'Display options')
	if(raw_mode) then
	  call help_key(control,help_des,key_byte,'Display byte',context)
	  call help_key(control,help_des,key_word,'Display word',context)
	  call help_key(control,help_des,key_long,'Display longword',context)
	  call help_key(control,help_des,key_display_octal,'Display Octal',context)
	  call help_key(control,help_des,key_display_binary,'Display binary',context)
	else
	  call help_key(control,help_des,key_getfields,
     1           'Enter fieldedit mode',context)
	  call help_key(control,help_des,key_contdis,'Display description',context)
	  call help_key(control,help_des,key_change_disp,
     1          'Change display layout',context)
	endif
	call help_key(control,help_des,key_display_decimal,'Decimal display',context)
	call help_key(control,help_des,key_display_hex,'Hex display',context)
c
	call help_key(control,help_des,key_dispall,'Show all formats',context)
	call help_key(control,help_des,key_viewvfc,'View/mod VFC data',context)
	call help_key(control,help_des,key_swap_num,'No-display offset',context)
	if(raw_mode) then
	  call help_key(control,help_des,key_compres,
     1                  'Toggle singed/unsigned',context)
	else
	  call help_key(control,help_des,key_compres,'Compress on/off',context)
	endif
	call help_key(control,help_des,key_hexdeco,'Hex/decimal offset',context)
	call help_key(control,help_des,key_swap_dis,'Raw/interpret mode',context)
	call help_key(control,help_des,key_print,'Print record',context)
	call help_key(control,help_des,key_ch_width,'Toggle 80/132 cols',context)
c
	if (has_des) then
	  call help_topic(help_des,'Description files')
	  call help_key(control,help_des,key_nextdes,'Next des file',context)
	  call help_key(control,help_des,key_prevdes,'Prev des file',context)
	  call help_key(control,help_des,key_viewdes,'View des file',context)
	  call help_key(control,help_des,key_viewdesc,
     1              'View internal desrecords',context)
	  call help_key(control,help_des,key_dirdes,'Dir of des files',context)
	  call help_key(control,help_des,key_editdes,'Edit description',context)
	endif
	call help_topic(help_des,'File/record')
	call help_key(control,help_des,key_next_rec,'Read next rec',context)
	call help_key(control,help_des,key_prev_rec,'Read prev rec',context)
	call help_key(control,help_des,key_ask_key,
     1        'Ask for key and read',context)
	call help_key(control,help_des,key_fileinfo,'File info',context)
	call help_key(control,help_des,key_put,'Insert record',context)
	call help_key(control,help_des,key_remove,'Delete current record',context)
	call help_key(control,help_des,key_newreclen,'Change recordlength',
     1                context)
	call help_key(control,help_des,key_find_rec,
     1              'Search file for string',context)
	call help_key(control,help_des,key_find_rec1,
     1              'Ask for string and search file',context)
	call help_key(control,help_des,key_next_file,'Next file',context)
	call help_key(control,help_des,key_prev_file,'Prev file',context)
	call help_key(control,help_des,key_dir_file,'Dir files',context)
	call help_key(control,help_des,key_follow_link,'Follow link',context)
	call help_topic(help_des,'General')
	call help_key(control,help_des,key_do,'Save changes',context)
	call help_key(control,help_des,key_abort,
     1            'Restore record to original',context)
	call help_key(control,help_des,key_save,'Save data(cut)',context)
	call help_key(control,help_des,key_restore,
     1                'Restore from last save',context)
	call help_key(control,help_des,key_help,'Display help',context)
	call help_key(control,help_des,key_exit,'Exit',context)
	call help_key(control,help_des,key_modechange,
     1               'Change mode to interactive',context)
	call help_topic_2(help_des,'Left mouse','Go to this line')
        call help_topic_2(help_des,'Middle mouse','Scroll up/down')
        call help_topic_2(help_des,'Right mouse','Start menu')
	call help_key(control,help_des,key_menu,'Menu',context)
	call help_key(control,help_des,key_mouse_toggle,
     1               'Toggle mouse usage',context)
c
	return
	end
	subroutine dix_dump_screen_view_des(control,des_info)
	implicit none
c
	include 'dix_def.inc'
	record /control/ control
	record /des_info/ des_info
c#
c We need a scratch file to get all data
c
	call lib$get_lun(control.lun_out)
	open(control.lun_out,type='scratch',carriagecontrol='list')
	call dix_dump_print_par(control,des_info.parameters.count,
     1        %val(des_info.parameters.address),'*',.false.)
	call dix_dump_print_line_int(control,des_info.table_nor.count,
     1        %val(des_info.table_nor.address),
     1             des_info.first_nor_var)
	call dix_dump_print_line_int(control,des_info.table_vfc.count,
     1        %val(des_info.table_vfc.address),
     1             des_info.first_vfc_var)
c
c Now let smg look at it
c
	rewind(control.lun_out)
	call dix_smg_view_file(control,control.lun_out,
     1         'Current expanded description')
	close(control.lun_out)
	call lib$free_lun(control.lun_out)
	control.lun_out = 0
	return
	end	
	subroutine dix_dump_screen_dis_recnr(dis_kop,recnr,hex,got_rec)
	implicit none
c
	include 'dix_def.inc'
c
	integer dis_kop
	integer*4 recnr
	logical hex
	logical*4 got_rec
c#
	include '($smgdef)'
	character*(max_nr_asc_length+2) line
	integer nk
c
	nk = 0
	if(recnr .gt. 0 .and. got_rec) then
	  if(hex) then
c 
c In hex format
c
	    call dix_util_hex_conv(recnr,line,nk,.true.)
	  else
	    call sys$fao('!UL',nk,line,%val(recnr))
	  endif
	  line(nk+1:) = ' '
	else
	  line = 'Unknown'
	end if
	call smg$put_chars(dis_kop,line,2,46,,
     1            smg$m_bold .or. smg$m_reverse)
	return
	end
	subroutine dix_dump_screen_dis_recsiz(dis_kop,recsiz,hex)
	implicit none
c
	include 'dix_def.inc'
c
	integer dis_kop
	integer*4 recsiz
	logical hex
c#
	include '($smgdef)'
	character*(max_nr_asc_length+2) line
	integer nk
c
	nk = 0
	if(hex) then
c 
c In hex format
c
	  call dix_util_hex_conv(recsiz,line,nk,.true.)
	else
	  call sys$fao('!UL',nk,line,%val(recsiz))
	endif
	line(nk+1:6) = ' '
	call smg$put_chars(dis_kop,line(1:6),2,8,,
     1            smg$m_bold .or. smg$m_reverse)
	return
	end
	subroutine dix_dump_screen_display_hdr_1(control,file)
	implicit none
c
	include 'dix_def.inc'
	include '($smgdef)'
c
	record /control/ control
	record /file_info/ file
c#
	integer*4 nk
	character*(max_screen_width) line
c
	call lib$trim_filespec(file.fnam,line,control.ncols-20,nk)
	line(nk+1:) = ' '	
        call smg$put_chars(control.dis_kop,'File :',
     1             1,1,,smg$m_reverse)
        call smg$put_chars(control.dis_kop,line,
     1             1,7,,smg$m_bold .or. smg$m_reverse)
        if(file.fixed) then
          line = 'Fix/'
        else
          line = 'Var/'
        end if
        if(file.indexed) then
          line(5:7) = 'Idx'
        elseif(file.relative) then
          line(5:7) = 'Rel'
        else
          line(5:7) = 'Seq'
        end if
        if (file.modify) line(8:11) = '/MOD'
        if (file.block_size .ne. 0) line(12:15) = '/BLK'
        call smg$put_chars(control.dis_kop,line(1:15),1,
     1            control.ncols-14,,smg$m_reverse .or. smg$m_bold)
	if(file.block_size .eq. 0) then
          line   = 'Recsiz:       Offs:         '//
     1             'Data:      Recnr:           RFA:'
	else
          line   = 'Recsiz:       Offs:         '//
     1             'Data:      Blknr:           RFA:'
	endif
c
        call smg$put_chars(control.dis_kop,line(1:control.ncols),2,1,,
     1                 smg$m_reverse)

	return
	end  
	subroutine dix_dump_screen_display_hdr_2(control,file,dis)
	implicit none
c
	include 'dix_def.inc'
	record /control/ control
	record /file_info/ file
	record /dis_pars/ dis
c
c Update the 2nd header line after a new record is read
c
c Display the record size
c
	call dix_dump_screen_dis_recsiz(control.dis_kop,file.data.nb_data,
     1                  dis.number_hex)
c
c And the record number
c
	call dix_dump_screen_dis_recnr(control.dis_kop,file.rec_nr,
     1                  dis.number_hex,file.got_record)
c
c And display the rfa
c
	call dix_dump_screen_dis_rfa(control.dis_kop,file,dis.number_hex)
	return
	end

	subroutine dix_scr_truncate(line,nk_min,extra)
	implicit none
c
	character*(*) line	!:io: the line
	integer*4 nk_min	!:i: the width to clip to
	logical extra		!:i: do we need an extra space for >
c#
	integer*4 nk_act 
	integer*4 dix_util_get_len
c
	nk_act = dix_util_get_len(line)
	if(extra) nk_act = nk_act + 1
	if(nk_act .gt. nk_min) line = '.'//line(nk_act-nk_min+2:nk_act)
	return
	end
	function dix_dump_s_get_keys(file,control)
	implicit none
c
	include 'dix_def.inc'
	record /file_info/ file
	record /control/ control
	integer*4 dix_dump_s_get_keys
c#
	include '($smgdef)'
	include '($smgmsg)'
c
	character*(*) help_lines_idx
	character*(*) help_lines_dir
c
	parameter (help_lines_idx =
     1    'input for indexed files;'//
     1    'The user can specify the key 0..nkey-1 or a ?;'//
     1    'And a value and a keyoption (EQ,LE,LT,GE,GT);'//
     1    'If the value is empty, the program will rewind on this key')
c
	parameter (help_lines_dir=
     1    'input for sequential files;'//
     1    'The user can specify a record number;'//
     1    'If the file allows direct access, the program will;'//
     1    'read the record, else the program will rewind and;'//
     1    'skip recnr-1 records')
c
	integer*4 dis_id,iterm,key1,keyopt,istat,nk,ios 
	logical*4 string,ascending
	integer*4 length
	character*(max_rms_key_name_length) keynam
	character*(max_line_length) line
c
	logical*4 dix_main_get_record
	logical*4 dix_rms_keyinfo
c	integer*4 smg$select_from_menu
	integer*4 dix_smg_select_menu
c
	integer*4 nkar_key,nkar
	external dix_msg_illkey
c	external dix_msg_aslelt
c	external dix_msg_degegt
	external dix_msg_noval
	external dix_msg_rewind
	external dix_msg_keynotf
	external dix_msg_illrecn
c
	character*(max_short_line_length) choise
c
	call smg$create_virtual_display(5,50,dis_id,smg$m_border)
	call smg$paste_virtual_display(dis_id,control.paste_id,10,10)
	call smg$label_border(dis_id,'Keyinformation')
c
	if(file.indexed) then
c
c For indexed file we need 
c  keynr, options(eq,ge,gt), and key_value
c
c Get key number
c first DIsplay key info
c
10	  call smg$put_chars(dis_id,'Key :',1,1)
	  call dix_rms_keyinfo(file,file.cur_key,
     1                string,length,ascending,keynam)
c
	  call dix_con_type_intasc(4,file.cur_key,enttyp_int,
     1                             line,nkar,control)
	  call smg$put_chars(dis_id,line(1:nkar),1,7)
	  call smg$put_chars(dis_id,keynam,1,10)
C
	  call smg$put_chars(dis_id,keynam,1,10)
	  if(ascending) then
	    call smg$put_chars(dis_id,'Ascending',2,8)
	  else
	    call smg$put_chars(dis_id,'Descending',2,8)
	  end if
	  if(string) then
	    call smg$put_chars(dis_id,'String',2,19)
	  else
	    call smg$put_chars(dis_id,'Numeric',2,19)
	  endif
c         
c Get key number
c
	  iterm = 0
	  call dix_smg_stack_help(control,help_lines_idx)
	  call dix_smg_get_string(control,dis_id,1,7,2,line,0,
     1                              iterm,nk,.false.)
	  call dix_smg_unstack_help(control)
	  if(iterm .eq. key_exit) goto 80
	  if(line .eq. '?') then
	    call dix_dump_s_select_key_from_menu(control,file,key1)
	    if(key1 .ge. 0) then
	      call sys$fao('!UL',nk,line,%val(key1))
	      call smg$put_chars(dis_id,line(1:nk),1,7)
	    endif
	  else
	    read(line(1:nk),2000,iostat=ios) key1
2000	    format(bn,i10)
	    if(ios .ne. 0) key1 = -1
	  endif
	  if(key1 .lt. 0 .and. key1 .ge. file.nkey) goto 30
	  if(dix_rms_keyinfo(file,key1,string,length,
     1               ascending,keynam)) goto 40
c
30	  call dix_message(control,dix_msg_illkey,line(1:nk))
	  call dix_rms_keyinfo(file,file.cur_key,string,
     1                    length,ascending,keynam)
	  goto 10
c
c Valid key, now get value
c SMG mode : LEt the user specify eq,ge(le) or gt(lt)
c
40	  call smg$put_chars(dis_id,keynam,1,10)
	  if(ascending) then
	    call smg$put_chars(dis_id,'Ascending',2,8)
	  else
	    call smg$put_chars(dis_id,'Descending',2,8)
	  end if
	  if(string) then
	    call smg$put_chars(dis_id,'String',2,19)
	  else
	    call smg$put_chars(dis_id,'Numeric',2,19)
	  endif
c
c Got valid key
c
	  call smg$put_chars(dis_id,'Value :',3,1)
c
c Now get keyvalue
c
	  iterm = 0
	  call dix_smg_stack_help(control,help_lines_idx)
	  call dix_smg_get_string(control,dis_id,3,8,32,line,0,iterm,
     1                 nkar_key,.false.)
	  call dix_smg_unstack_help(control)
	  if(iterm .eq. key_exit) goto 80
	  if(iterm .eq. key_first) goto 10
	  if(nkar_key .eq. 0) then
	    file.cur_key = key1
	    call dix_message(control,dix_msg_rewind)
	    goto 50
	  end if
c
	  istat = dix_smg_select_menu(control,'LT,LE,EQ,GE,GT',choise,
     1                    .true.,' ',13,15,.false.)
          if(istat .eq. smg$_eof) goto 80
	  if(choise(1:2) .eq. 'EQ') then
	    keyopt = key_opt_eq
	  elseif(choise(1:2) .eq. 'LE') then
	    keyopt = key_opt_le
	  elseif(choise(1:2) .eq. 'LT') then
	    keyopt = key_opt_lt
	  elseif(choise(1:2) .eq. 'GE') then
	    keyopt = key_opt_ge
	  elseif(choise(1:2) .eq. 'GT') then
	    keyopt = key_opt_gt
	  else
	    goto 80
	  endif
	else
c
c Non indexed file, we only accept recordnumber
c
60	  call smg$put_chars(dis_id,'Recordnumber :',1,1)
	  line = ' '
	  call smg$put_chars(dis_id,line(1:10),1,15)
	  iterm = 0
	  call dix_smg_stack_help(control,help_lines_dir)
	  nk = 10
	  call dix_smg_get_string(control,dis_id,1,15,nk,
     1             line(1:nk),0,iterm,nkar_key,.false.)
	  call dix_smg_unstack_help(control)
	  keyopt = key_opt_seq
	endif
50	istat = dix_main_get_record(control,file,key1,keyopt,
     1              line(1:nkar_key),.true.)
	goto 90
80	istat = 1
90	call smg$delete_virtual_display(dis_id)
	dix_dump_s_get_keys = istat
	return
	end
	subroutine dix_dump_s_select_key_from_menu(control,file,key1)
	implicit none
c
c LEt the user select a key via a menu
c
	include 'dix_def.inc'
	record /control/ control
	record /file_info/ file
	integer*4 key1
c#
	include '($smgdef)'
	integer*4 iterm,sel_id,ipos,k,nkey,minr,maxr,length,krow,kcol
	character*(max_line_length) line
	record /dyn_help/ help_des
c
c assume error
c
	character*(max_rms_key_name_length) keynam
	logical*4 ascending,string
c
	character*(*) context
	parameter (context = 'SELKEY')
c
	call help_init_std(control,help_des,'select key',20,2,context)
	call help_key(control,help_des,key_enter,
     1                'select the current key',context)
	call help_key(control,help_des,key_exit,
     1                'Exit this screen',context)
	call dix_smg_stack_help(control,help_des)
c
	call dix_rms_get_reclen(%val(file.rabadr),minr,maxr,nkey)
	call smg$create_virtual_display(nkey,50,sel_id)
	call smg$put_chars(sel_id,'Key  Size String Ascending name',1,1)
	do k=0,nkey-1
	  call dix_rms_keyinfo(file,k,string,length,ascending,keynam)
	  write(line,'(i3,i6)') k,length
	  line(11:16) = '   No'	
	  if(string) line(11:16) = '  Yes'	
	  line(18:26) = '       No'	
	  if(ascending) line(18:26) = '      Yes'	
c
	  line(28:) = keynam
	  call smg$put_chars(sel_id,line,k+2,1)
	end do
	call smg$label_border(sel_id,'Keyselection')
	call smg$paste_virtual_display(sel_id,control.paste_id,
     1                2,control.ncols-51)
	key1 = -1
	ipos = 0
c
10	call smg$set_cursor_abs(sel_id,ipos+2,1)
	call dix_get_key(control,iterm,krow,kcol,' ')
	if(iterm .eq. key_up) then
	  if(ipos .gt. 0) ipos = ipos - 1
	elseif(iterm .eq. key_down) then
	  if(ipos .lt. nkey-1) ipos = ipos+1
	elseif(iterm .eq. key_help) then
	  call dix_smg_help(control,context)
	elseif(iterm .eq. key_enter) then
	  key1 = ipos
	  goto 90
	elseif(iterm .eq. key_exit) then
	  key1 = -1
	  goto 90
	endif
	goto 10
90	call smg$delete_virtual_display(sel_id)
	call dix_smg_unstack_help(control)
	call help_exit(help_des)
	return
	end
	subroutine dix_dump_Screen_display_scr(control,disp,
     1             des_expanded,vfc,dis,file,has_fields)
	implicit none
c
	include 'dix_def.inc'
	include 'dix_screen_def.inc'	
	include '($smgdef)'
c
	record /control/ control
	record /display_data_des/ disp
	record /des_expanded/ des_expanded
	logical vfc
	record /dis_pars/ dis
	record /file_info/ file
	logical*4 has_fields
c
	integer*4 k,ndes,offs,nbdata,max_len,nlines,ibpos,iepos
	integer*4 nkar,video,l,nk_disp,nk_min,nk_min_org,m
	logical skip
c
	character*(max_line_length) line
	character*(max_command_length) regel,vid_line
	character*(max_nr_asc_length) nroff
c
	record /des_rec/ des_recs(*)
	pointer (p_des_recs,des_recs)
c
	logical*4 dix_rms_offset_in_key
c
	nlines = 0
	disp.n_admins = 0
	disp.n_des = 0
	disp.screen.ncols = 0		!max width
	if(vfc) then
	  nk_min_org = des_expanded.vfc_max_name_size
	  ndes = des_expanded.table_vfc.count
	  nbdata = file.data.nb_vfc
	else
	  nk_min_org = des_expanded.max_name_size
	  ndes = des_expanded.table_nor.count
	  nbdata = file.data.nb_data
	endif
c
	nk_min = min(control.ncols/2,nk_min_org)
c
c Compute the size of the offset field form the max data offset
c nk_min is the length of the longest field name
c
	if(dis.number) then
	  disp.nk_off = 0
	  call dix_util_con_nr(nbdata*bits_per_byte,has_fields,nroff,
     1              disp.nk_off,
     1              dis.number_hex,control)
	  nk_disp = nk_min + disp.nk_off + 1		!+ nk_off digits and 1 :
	else		
	  nk_disp = nk_min 
	end if
c
	disp.ncol_offset    = nk_disp+1
	disp.screen.view_ncols = control.ncols - disp.ncol_offset 
c
	do k=1,ndes
c
c Get description
c
	  
	  if(vfc) then
	    p_des_recs = des_expanded.table_vfc.address
	  else
	    p_des_recs = des_expanded.table_nor.address
	  endif
c
c See if user wants to not display this field
c two reasons
c  1. user set this field to nodisplay
c  2. user set compress and this field is "zero"
c	
	  skip = (des_recs(k).flags .and. des_flag_no_display) .ne. 0
	  if(.not. skip) then
	    if(dis.compres) then
	      skip = (des_recs(k).flags .and. des_flag_compressed) .ne. 0
	    endif
	  endif
	  if(.not. skip) then
	    disp.n_des = disp.n_des + 1
	    offs = des_recs(k).bit_offset  / bits_per_byte
	    if(offs .lt. nbdata) then
	      disp.n_admins = disp.n_admins + 1
c
c Convert the data to ascii
c
	      if(vfc) then
	        call dix_con_intasc(nbdata-offs,des_recs(k),
     1              file.data.vfc_data,regel,nkar,
     1              dis.hex,max_len,control)
	      else
	        call dix_con_intasc(nbdata-offs,des_recs(k),
     1              file.data.data_rec,regel,nkar,
     1              dis.hex,max_len,control)
	      endif
	      disp.admins(disp.n_admins).row_number = nlines + 1
	      disp.admins(disp.n_admins).idx_des = k
	      video = 0
c
c If the data overlaps with the current key, mark it reversed
c
	      if(.not. vfc) then
	        if(dix_rms_offset_in_key(file,offs,
     1                 des_recs(k).size/bits_per_byte))
     1            video = smg$m_reverse
	      endif
	      l = 1
c
c Compute #lines needed, since nkar could be 0, always user 1 line
c
	      if(control.wide_display) then
	        disp.admins(disp.n_admins).nlines = 1
c
c Make sure the display is wide enough
c
	        if(nkar .gt. disp.screen.disp_ncols) then
	          disp.screen.disp_ncols = nkar
	          call smg$change_virtual_display(disp.dis_id,,
     1                    disp.screen.disp_ncols)
	        endif
	      else
	        m = disp.screen.view_ncols
	        disp.admins(disp.n_admins).nlines = max(1,(nkar+m-1)/m)
	      endif
	      do while(nlines+1+disp.admins(disp.n_admins).nlines .ge. 
     1            disp.screen.disp_nrows)
c
c Screen is not long enough, try expand it
c
	        disp.screen.disp_nrows = disp.screen.disp_nrows + 100
	        call smg$change_virtual_display(disp.dis_id,
     1                disp.screen.disp_nrows)
	        call smg$change_virtual_display(disp.dis_id_offset,
     1                disp.screen.disp_nrows)
	      end do
c
c Convert the byte offset
c
	      if(dis.number) then
	        call dix_util_con_nr(des_recs(k).bit_offset,
     1                    has_fields,nroff,disp.nk_off,
     1                    dis.number_hex,control)
	        call smg$put_chars(disp.dis_id_offset,nroff,nlines+1,1)
	        l = disp.nk_off+2
	      end if
c
c Display the field name
c
	      call dix_util_copy_string(des_recs(k).nam,line)
	      if(nk_min .lt. nk_min_org) then
	        call dix_scr_truncate(line,nk_min,des_recs(k).p_link_rec.ne.0)
	      endif
	      if(des_recs(k).p_link_rec .ne. 0) line(nk_min:nk_min) = '>'	    
	      call smg$put_chars(disp.dis_id_offset,line(1:nk_min),
     1                           nlines+1,l,,video)
c
c display the ascii data in (possibly) multiple lines 
c  or one line (if .wide_display is set)
c
	      ibpos =1
	      do l=1,disp.admins(disp.n_admins).nlines
	        nlines = nlines + 1
	        iepos = nkar
c
	        if(.not. control.wide_display) then
	          iepos = min(iepos,l*disp.screen.view_ncols)
	        endif
c
	        do m=ibpos,iepos
	          if(regel(m:m) .eq. char(0)) then
	            regel(m:m) = '.'
	            vid_line(m-ibpos+1:m-ibpos+1) = char(smg$m_reverse)
	          else
	            vid_line(m-ibpos+1:m-ibpos+1) = char(0)
	          endif
	        end do
	        disp.screen.ncols = max(iepos-ibpos+1,disp.screen.ncols) 
	        call smg$put_chars_multi(disp.dis_id,regel(ibpos:iepos),nlines,
     1                           1,smg$m_erase_to_eol,
     1                           vid_line(1:iepos-ibpos+1))
	        ibpos = iepos + 1
	      end do
	    end if	!still in data rec
	  endif		!compress
	end do
c
	disp.screen.nlines = nlines
c
c Draw line, (check for special cases  in nlines)
C  0: do nothing
C  1: draw single character
c
	if(disp.screen.nlines .eq. 0) then
	elseif(disp.screen.nlines .eq. 1) then
	  call                smg$draw_char(disp.dis_id_offset,smg$m_up,
     1                                      1,disp.ncol_offset)
	  if(dis.number) call smg$draw_char(disp.dis_id_offset,smg$m_up,
     1                                      1,disp.nk_off+1)
	else
	  call                smg$draw_line(disp.dis_id_offset,1,
     1                                      disp.ncol_offset   ,
     1                                      disp.screen.nlines,
     1                                      disp.ncol_offset)
	  if(dis.number) call smg$draw_line(disp.dis_id_offset,1,
     1                                      disp.nk_off+1,
     1                                      disp.screen.nlines,
     1                                      disp.nk_off+1)
	end if
	return
	end
c
	subroutine dix_smg_set_ptr_raw(control,krow,kcol,posasc,ascdis,
     1                                kpl,dis,fldsiz,in_vfc,
     1                                disp_dat,disp_vfc,p_disp)
	implicit none
c
c Update the pointer after mouse click at krow,kcol
c the field updated is disp.indx , it points to the new location
c
	include 'dix_def.inc'
	include 'dix_screen_def.inc'
	record /control/ control	!:i: control block
	integer*4 krow			!:i: klick row
	integer*4 kcol			!:i: klick col
	integer*4 posasc                !:i: start of ascii display
	logical*4 ascdis                !:io: are we in ascii display
	integer*4 kpl			!:i: #items/ line
	record /dis_pars/ dis           !:i: display params
	integer*4 fldsiz		!:i: width for decimal display
	logical*4 in_vfc		!:o: new setting for vfc
	record /display_data_raw/ disp_vfc !:i: display data for vfc window
	record /display_data_raw/ disp_dat !:i: display data for dat window
	record /display_data_raw/ disp      !:i: display data
	pointer (p_disp,disp)
c
	integer*4 k,l
c
	krow = krow - 3		!start at line 4
	if(krow .gt. disp_dat.screen.view_nrows) then
c
c User pointed in vfc data
c
	  p_disp = %loc(disp_vfc)
	  krow = krow + 3 - control.nrows + 1 + disp.screen.row_offset - 1
	  in_vfc = .true.
	else
c
c User pointed in normal window
c
	  p_disp = %loc(disp_dat)
	  krow = krow + disp.screen.row_offset - 1
	  in_vfc = .false.
	endif
c
	if(krow .ge. 1) then
	  krow = (krow-1) * kpl * bits_per_byte		!add previous full lines
c
c In window
c
	  if(kcol .gt. posasc .and. kcol .le. posasc + kpl) then
c
c User pointed in ascii display part
c 
	    ascdis = .true.
	    disp.indx = krow + bits_per_byte*(kcol-posasc-1)
	  elseif(kcol .lt. posasc) then
c
c Before the ascii display, so probably in the raw display
c  Hex/Octal/binary/decimal
c
c Compute block (examples for dis.word=4 and kpl=16)
c Each word is fldsiz-1 wide and one space in between
c
c          1         2
c 12345678901234567890123456789
c dddddddd dddddddd dddddddd dddddddd
c so pos 1-8 are valid, 10-17, etc
c  9,18,27,36 are invalid
c
	    kcol = kcol - 1
	    k    = kcol/(fldsiz) !k=0..3	
c
c Now see if we do not hit the space in between
c
	    if(mod(kcol,fldsiz)	.lt. fldsiz-1) then
c
c We are in the word field.
c Now we know the word 0..3
c
	      l = (kpl/dis.word - k - 1)
c
c Now the reversed word 3..0
c
	      disp.indx = krow + l*dis.word*bits_per_byte
	      ascdis = .false.
c
c Now compute the byte offset in the word
c
	      k = kcol - k*fldsiz   !now k = byte offset in word
	      if(dis.hex .eq. des_flag_translate_hex) then
c
c Now we can zoom in to the nibble
c
	        disp.indx = disp.indx + (dis.word*2 - k -1)*4 
	      elseif(dis.hex .eq. des_flag_translate_bin) then
c
c Now we can zoom in the the bit
c
	        disp.indx = disp.indx + dis.word*bits_per_byte - k - 1
	      endif
	    endif
	  endif
	endif
c
c And set the screen coordinates in disp
c
	return
	end
	subroutine dix_dump_screen_dis_rfa(dis_kop,file,hex)
	implicit none
c
	include 'dix_def.inc'
	integer*4 dis_kop
	record /file_info/ file
	logical*4 hex
c
	include '($smgdef)'
c
	character*(max_short_line_length) line
	integer*4 nk,nk1
c
	record /rfa/ rfa
c
	call dix_rms_return_rfa(file,rfa)
c
	if(hex) then
	  line = '('
	  nk = 1
	  call dix_util_hex_conv(rfa.bbnr,line(nk+1:),nk1,.true.)
	  nk = nk + nk1 + 1
	  line(nk:nk) = ','
	  call dix_util_hex_conv(zext(rfa.offset),line(nk+1:),nk1,.true.)
	  nk = nk + nk1 + 1
	  line(nk:nk) = ')'
	else
	  call sys$fao('(!UL,!UW)',nk,line,
     1          %val(rfa.bbnr),%val(rfa.offset))
	  line(nk+1:) = ' '
	endif
	call smg$put_chars(dis_kop,line(1:19),2,61,,
     1            smg$m_bold .or. smg$m_reverse)
	return
	end
	subroutine dix_dump_screen_raw_line(control,dis_id,linenr,kpl,file,dis,
     1                        posasc,fldsiz,in_vfc,line_offset)
	implicit none
c
c dump data bytes in raw mode on screen
c
	include 'dix_def.inc'
	record /control/ control	!:i: contol block
	integer*4 dis_id		!:i: display id
	integer*4 linenr		!:i: linenr requested
	integer*4 kpl			!:i: #bytes/line
	record /file_info/ file		!:i: file info
	record /dis_pars/ dis		!:i: display parameters
	integer*4 posasc		!:i: ascii position
	integer*4 fldsiz		!:i: field size
	logical*4 in_vfc		!:i: take data from vfc buffer
	integer*4 line_offset		!:i: line offset in display
c#
	integer*4 begpos_bol(50),endpos_bol(50)
	integer*4 n_bol,nkar,k
	character*(max_screen_width) line
c
	include '($smgdef)'
c
c Convert to ascii
c
	if(in_vfc) then
	  call dix_dump_raw_line(control,(linenr-1)*kpl,kpl,file.data.nb_vfc,
     1                file.data.vfc_data,dis,posasc,
     1                begpos_bol,endpos_bol,n_bol,line,nkar,
     1                fldsiz,file)
c
	else
	  call dix_dump_raw_line(control,(linenr-1)*kpl,kpl,file.data.nb_data,
     1                file.data.data_rec,dis,posasc,
     1                begpos_bol,endpos_bol,n_bol,line,nkar,
     1                fldsiz,file)
	endif
c
c To screen
c
	call smg$put_chars(dis_id,line(1:nkar),linenr+line_offset,1)
c
c Highlight key fields
c
	do k=1,n_bol
	  call smg$change_rendition(dis_id,
     1             linenr+line_offset,begpos_bol(k),
     1             1,endpos_bol(k)-begpos_bol(k)+1,smg$m_reverse)
	end do
c
	return
	end

