Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!mis.mcw.edu!tenaglia From: tenaglia@mis.mcw.edu (Chris Tenaglia - 257-8765) Newsgroups: comp.lang.icon Subject: Handy icon procedure make hex dumps of strings Message-ID: <9001031506.AA02111@uwm.edu> Date: 3 Jan 90 13:08:07 GMT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: inet Organization: The Internet Lines: 30 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