home *** CD-ROM | disk | FTP | other *** search
/ Vectronix 2 / VECTRONIX2.iso / FILES_01 / HISOFT.LZH / HISOFT_B.MSA / EXAMPLES / DUMP.BAS < prev    next >
BASIC Source File  |  1987-07-27  |  1KB  |  60 lines

  1. rem Dumps out a file in hex and ASCII
  2. rem following line turns pause & break checks on
  3. rem $option pb
  4.  
  5. deflng l,p,t    ' define long integers
  6. defint a,i        ' define integers
  7.  
  8. ' returns a two-digit hex string given an integer
  9. def fnbhex$(h%)
  10. local a$
  11. a$=hex$(h%): if len(a$)=1 then a$="0"+a$
  12. fnbhex$=a$
  13. end def
  14.  
  15. ' returns an 8-digit hex string given a long integer
  16. def fnlhex$(h&)
  17. local a$
  18. a$=hex$(h&): fnlhex$=string$(8-len(a$),"0"%)+a$
  19. end def
  20.  
  21.  
  22. ' the actual program
  23. f$=command$
  24. print "DUMP ";chr$(189);" HiSoft 1987 compiled in HiSoft BASIC"
  25.  
  26. repeat main
  27. if f$="" then input "Filename, ? for DIR, or [Return] to quit";f$
  28. if f$="" then
  29.     stop -1                'return without waiting
  30. elseif f$="?" then
  31.     files                'get a directory
  32. elseif not fexists(f$) then
  33.     print "Error: Cannot find file ";f$
  34. else
  35.     open "i",#2,f$,2000
  36.     l=lof(2)
  37.     p=0
  38.         repeat lineloop
  39.         t=16: if p+16>l then t=l-p
  40.         print fnlhex$(p);" ";
  41.         a$=input$(t,#2)
  42.         for i=1 to t
  43.             print fnbhex$(asc(mid$(a$,i,1)));" ";
  44.         next i
  45.         print tab(58);
  46.         for i=1 to t
  47.             if asc(mid$(a$,i,1))>31 then
  48.                 print mid$(a$,i,1);
  49.                 else
  50.                 print ".";
  51.             end if
  52.         next i
  53.         print
  54.         p=p+16: if p>l then exit lineloop
  55.         end repeat lineloop
  56.         close #2
  57. end if
  58. f$=""
  59. end repeat main
  60.