REBOL [ Title: "Char Test" File: %char-test.r Author: "Ingo Hohmann" EMail: ingo@2b1.de Site: http://www.2b1.de/Rebol/ Category: 'utility Version: 0.0.1 Purpose: { Counts characters in a file prints line numbers of characters less than #"^/" or greater than #"~" } Usage: { do the file, it asks for the filename } status: 'little-hack ] while [true] [ file: ask "File to Check: " if not error? try [ data: read to-file file ] [ break ] prin ["^/File not found, current dir is: " what-dir] print "^/Please try again^/" ] list: make hash! [] ; find/case didn't work, so I create all lower case characters, first for i 97 122 1 [ append list compose [(to-char i) 0] ] print "Reading ..." line: 1 for i 1 (length? data) 1 [ char: pick data i either found? pos: find/case list char [ pos: next pos count: (first pos) + 1 change pos count ][ ;print "new" append list char append list 1 ] if char = #"^/" [ ++ line ] if any [ (char < #"^/") (char > #"~") ] [ print [ mold char " " line ] ] ] prin "done^/Sorting ..." list2: copy [] foreach [char count] list [ append/only list2 compose [(char) (to-integer char) (count)] ] sort/compare list2 func [a b] [(first a) < first b] print "done^/^/Statistics" print [ "Lines: " line ] print [ "Characters: " length? data "^/^/char code count^/"] foreach entry list2 [ print mold entry ]