home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / DEMOS / UB_68000.LZH / fdump.b < prev    next >
Text File  |  1996-05-20  |  1KB  |  66 lines

  1. * FDUMP file dump program 
  2.  
  3.  dim character:byte
  4.  dim filenum:byte
  5.  dim filename:string[32]
  6.  dim bytectr:long
  7.  dim addrctr:long
  8.  dim ascii:string[16]
  9.  dim hex:string[49]
  10.  
  11.  addrctr=0
  12.  on error goto badfile
  13.  filename=NextArg
  14.  if len(filename)=0 then help
  15.  if filename="-?" or filename="--help" then help
  16.  open #filenum,filename:read+binary
  17. lp1
  18.  bytectr=0
  19.  ascii="                "
  20.  hex=zhex$(addrctr)+" "
  21.  addrctr=addrctr+16
  22. lp2
  23.  gosub getbyte
  24.  if STATUS<1 then
  25.         if bytectr>0 then
  26.                  gosub display
  27.         endif
  28.         end
  29.  endif
  30.  inc bytectr
  31.  if character>$1f and character<$7f then
  32.         mid$(ascii,bytectr,1)=chr$(character)
  33.  else
  34.         mid$(ascii,bytectr,1)="."
  35.  endif
  36.  hex=hex+right$(zhex$(character),2)
  37.  if mod(bytectr,4)=0 then
  38.         hex=hex+" "
  39.  endif
  40.  if bytectr=16 then
  41.         gosub display
  42.         goto lp1
  43.  else
  44.         goto lp2
  45.  endif
  46.  
  47. display
  48.  print hex;tab(52);ascii
  49.  return
  50.  
  51. getbyte
  52.  get #filenum,character
  53.  return
  54.  
  55. badfile
  56.  print "cannot open ";filename
  57.  end
  58.  
  59. help
  60.  print
  61.  print "fdump filename"
  62.  print "performs hexadecimal and ascii dump of file specified"
  63.  print
  64.  end
  65.  
  66.