[Richard Suchenwirth] 2004-04-23 - Yet another tiny fun project, here's how to convert a string of digits and some other characters to a multiline string that in a fixed-pitch font looks like a 7-segment LCD/LED display: proc num->7seg string { foreach i {a b c} {set $i " "} array set 7segment { 0 {{ _ } {| |} {|_|}} 1 {{ } { |} { |}} 2 {{ _ } { _|} {|_ }} 3 {{ _ } { _|} { _|}} 4 {{ } {|_|} { |}} 5 {{ _ } {|_ } { _|}} 6 {{ _ } {|_ } {|_|}} 7 {{ _ } { |} { |}} 8 {{ _ } {|_|} {|_|}} 9 {{ _ } {|_|} { _|}} - {{ } { _ } { }} E {{ _ } {|_ } {|_ }} r {{ } { _ } {| }} o {{ } { _ } {|_|}} } foreach char [split $string ""] { if {$char eq "."} { set c [string replace $c end end .] } else { foreach i {a b c} row $7segment($char) { append $i $row " " } } } return $a\n$b\n$c } % num->7seg 1234567890-Error _ _ _ _ _ _ _ _ _ | _| _| |_| |_ |_ | |_| |_| | | _ |_ _ _ _ _ | |_ _| | _| |_| | |_| _| |_| |_ | | |_| | ---- [Arts and crafts of Tcl-Tk programming]