Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: dump-binary

From: jvargas:whywire at: 1-May-2004 20:50

Thank you all for the input. Below is a new version of dump-bin that includes Ashley's suggestions. Hallvard you got my permission to include in prob.r. Greg, I think your suggestion that probe should produce output similar to dump-bin by default is great. I hope Carl goes for it. Finally, I hope to be posting other code snippets soon. I am working on a ssh scheme for rebol versions that support encryption. I am thinking about releasing it to the public, but first I need to figure out the licensing terms. Cheers, Jaime -- The best way to predict the future is to invent it -- Alan Kay dump-bin: func [ "Print ASCII info for entire binary. (for debugging)" bin [binary!] /local v t c r pad pl len chars tmp ][ chars: charset [#"a" - #"z" #"A" - #"Z" #"0" - #"9" #"-"] t: to-integer divide len: length? bin 16 r: remainder len 16 pl: either odd? r [40 - (5 * (r - 1) / 2)][40 - (5 * r / 2)] pad: head insert/dup copy {} #" " pl for j 0 t 1 [ prin head insert/dup tmp: to-string j "0" 4 - length? tmp prin ":^-" ; first print the hex format c: either j = t [r][16] repeat i c [ prin lowercase at to-hex pick bin (j * 16 + i) 7 if equal? i // 2 0 [prin " "] ] if all [r <> 0 j = t] [prin pad] either j <> t [prin "^-|^- "][if r <> 0 [prin "^-|^- "]] ; now print the ascii character repeat i c [ prin either find chars v: to-char pick bin (j * 16 + i) [v][#"."] ] prin newline ] ]