home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OL.LZH / PROCS.LZH / PHONAME.ICN < prev    next >
Text File  |  1991-09-06  |  1KB  |  58 lines

  1. ############################################################################
  2. #
  3. #    Name:    phoname.icn
  4. #
  5. #    Title:    Generate letter combinations for phone numbers
  6. #
  7. #    Author:    Thomas R. Hicks
  8. #
  9. #    Date:    June 10, 1988
  10. #
  11. ############################################################################
  12. #
  13. #     This procedure generates the letter combinations corresponding to the
  14. #  digits in a telephone number.
  15. #
  16. #  Warning:
  17. #
  18. #     The number of possibilities is very large. This procedure should be
  19. #  used in a context that limits or filters its output.
  20. #
  21. ############################################################################
  22.  
  23. procedure phoname(number)
  24.  
  25.     local buttons, nondigits, pstr, t, x
  26.  
  27.  
  28.     buttons := ["000","111","abc","def","ghi","jkl","mno", "prs","tuv","wxy"]
  29.     nondigits := ~&digits
  30.  
  31.     pstr := stripstr(number,nondigits)
  32.  
  33.     if 7 ~= *pstr then fail
  34.     t := []
  35.     every x := !pstr do
  36.     put(t,buttons[x+1])
  37.     
  38.     suspend !t[1] || !t[2] || !t[3] || !t[4] || !t[5] || !t[6] || !t[7]
  39.  
  40. end
  41.  
  42. procedure stripstr(str,delchs)
  43.  
  44.     local i
  45.  
  46.     i := 1
  47.     while i <= *str do
  48.     {
  49.     if any(delchs,str,i) then
  50.         str[i] := ""
  51.     else
  52.         i +:= 1
  53.     }
  54.  
  55.     return str
  56.  
  57. end # stripstr
  58.