10 ! rich gregory 8/23/85
   declare &
	string	outstring, &
		instring, &
		ref_str, &
		temp_str, &
		term, &
	word	i, &
		length_str, &
		temp_nbr, &
		which_key

	external string function hex_out ( word )

	!+==========================================

	! begin

	print 'Enter the string to be stored '
	linput instring
	print 'Enter the number of the key (6-20, help=15, do=16)'
	input which_key
	term = ' '
	while pos ('NCT', term, 1) = 0
	  print 'Do you want a terminator ' + &
	        '(C for return, T for tab, or N for nothing)'
	  input term
	  term = edit$ (term, 32)
	next ! while

	select which_key
	  case 11 to 14
	    which_key = which_key + 1
	  case 15 to 16
	    which_key = which_key + 2
	  case 17 to 20
	    which_key = which_key + 3
	  case else
	    !noop
	end select
	which_key = which_key + 11

	outstring = esc + 'P1;1|' + str$(which_key) + '/'
	ref_str = '<esc> P1;1|' + str$(which_key) + '/'

	length_str = len (instring)
	for i = 1 to length_str
	  temp_nbr = ascii ( seg$(instring, i, i))
	  temp_str = hex_out ( temp_nbr )
	  outstring = outstring + temp_str
	  ref_str = ref_str + temp_str + ' '
	next i
	if term = 'T'
	  then 
	    term = '09 '
	end if
	if term = 'C'
	  then term = '0d'
	end if
	if term = 'N'
	  then term = ' '
	end if

	ref_str = ref_str + ' <esc>\'
	print outstring, term, esc, '\'
	print ' here is the string    ', ref_str
   end

15000	function string hex_out ( word dec_in )
	
	declare &
	  string	t1, &
			t2, &
	  word		i, &
			j

	! begin

	i = dec_in / 16
	t1 = str$ (i)
	j = dec_in - (i*16)
	if j < 10
	  then
	    t2 = str$ (j)
	  else
	    t2 = string$ (1, j+55)
	end if
 !	print t1, '  ', t2, '  hex chars '
	hex_out = t1 + t2
	end function
