[comp.lang.icon] Handy icon procedure make hex dumps of strings

tenaglia@mis.mcw.edu (Chris Tenaglia - 257-8765) (01/03/90)

I have another handy but small procedure. It's called dump(str). It's
chiefly a debugging tool. It has to linked with radcon however. dump(str)
converts a string of unknown bytes into a list of hexidecimal formatted
ascii. The string "Hello" becomes list ["48","65","6C","6C","6F"]. This
can be output nicely with the expression : every writes(!dump(str),"  ")

-------------------------------------------------------------------------

##################################################################
#                                                                #
# THIS PROCEDURE CONVERTS A MYSTERY STRING TO A HEX DUMP LIST    #
#                                                                #
##################################################################
procedure dump(Str)             # REQUIRES LINK RADCON !
  Buffer := []
  every put(Buffer,right(map(radcon(ord(!Str),10,16),&lcase,&ucase),2,"0"))
  return Buffer
  end

---------------------------------------------------------------------------

Perhaps it could have been done better as a generator or coexpression.
Any ideas for improvements?

Chris Tenaglia (System Manager)
Medical College of Wisconsin
8701 W. Watertown Plank Rd.
Milwaukee, WI 53226
(414)257-8765
tenaglia@mis.mcw.edu