home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP21.EXE / CHP2110.PRG < prev    next >
Encoding:
Text File  |  1991-04-30  |  916 b   |  42 lines

  1. /*
  2.    Listing 21.10  Hexdump()
  3.    Author: Joe Booth
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063.4728 415) 366-3600
  8. */
  9.  
  10. //─────  must compile with the /N option!
  11.  
  12. #define BUF_SIZE  200
  13.  
  14. function hexdump(cFilename)
  15. LOCAL fh := Fopen(cFilename)
  16. LOCAL buf:= space(BUF_SIZE),spot,jj,tt
  17. if fh > -1
  18.    while Fread(fh,@buf,BUF_SIZE) = BUF_SIZE
  19.       for jj=1 to 10
  20.          ?
  21.          for tt= 1 to 20
  22.             spot := (jj-1) * 20 + tt
  23.             ?? dec2hex(asc(substr(buf,spot,1)))+" "
  24.          next
  25.       next
  26.    enddo
  27.    jj :=0
  28.    ?
  29.    while !empty(buf)
  30.       jj ++
  31.       ?? dec2hex(asc(substr(buf,1,1)))+" "
  32.       buf := substr(buf,2,len(buf))
  33.       if jj=20
  34.          jj=0
  35.          ?
  36.       endif
  37.    enddo
  38. endif
  39. return NIL
  40.  
  41. // end of file CHP2110.PRG
  42.