util_numeric_to_sql_sets

one of the documented procedures in this installation of the ACS
Usage:
util_numeric_to_sql_sets   a_few_chars
What it does:
Returns letters corresponding to the digits on a phone, as a list suitable for a sql select, i.e. passing in 2 returns ('a','b','c')
Defined in: /web/philip/tcl/intranet-wap-defs.tcl

Source code:


    if ![string length $a_few_chars] {
	return {}
    } else {
	set result [list]
	set lower_chars [string tolower $a_few_chars]
	for {set i 0} {$i<[string length $lower_chars]} {incr i} {
	    set one_char [string range $lower_chars $i $i]
	    set char_equiv_list [list]
	    if [regexp {[a-z]} $one_char] {
		lappend char_equiv_list $one_char
	    } else {
		switch $one_char {
		    2 { lappend char_equiv_list a b c }
		    3 { lappend char_equiv_list d e f }
		    4 { lappend char_equiv_list g h i }
		    5 { lappend char_equiv_list j k l }
		    6 { lappend char_equiv_list m n o }
		    7 { lappend char_equiv_list p q r s }
		    8 { lappend char_equiv_list t u v }
		    9 { lappend char_equiv_list w x y z }
		}
	    }
	    if [llength $char_equiv_list] {
		set char_equiv_sql {(}
		foreach char_equiv $char_equiv_list {
		    append char_equiv_sql '$char_equiv',
		}
		lappend result "[string trim $char_equiv_sql ,])"
	    }
	}
    }
    return $result


philg@mit.edu