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

  1. ############################################################################
  2. #
  3. #    Name:    morse.icn
  4. #
  5. #    Title:    Convert string to Morse code
  6. #
  7. #    Author:    Ralph E. Griswold, modified by Rich Morin
  8. #
  9. #    Date:    June 26, 1990
  10. #
  11. ############################################################################
  12. #
  13. #     This procedure converts the string s to its Morse code equivalent.
  14. #
  15. #     The version used is known both as International Morse Code and as
  16. #     Continental Code, and is used by radio amateurs (hams).
  17. #
  18. ############################################################################
  19.  
  20. procedure morse(s)
  21.    local i, c, t, x
  22.    static code, key1, key2
  23.  
  24.    initial {
  25.       code := "....------.----..---.-.---...--.--._
  26.                -..--..-.--....-.-.-...-..-....."
  27.       key1 := "tmot09ttt1t8tt2gqtttjtz7t3nky(tcttt_
  28.                tdx/twptb64earttltvtiuftsh5"
  29.       key2 := "tttttttttt'tt,ttttttttt:tttttt)tttt_
  30.                t?tttttttt-ttt.;tttttt\"tttt"
  31.    }
  32.  
  33.    x := ""
  34.    every c := !map(s) do
  35.       if i := upto(c, key1) then {
  36.          t := code[i+:6]
  37.          x ||:= t[ upto("-",t)+1 : 0 ] || " "
  38.       }
  39.       else if i := upto(c, key2) then
  40.          x ||:= code[i+:6] || " "
  41.       else if c == " " then
  42.          x ||:= "    "
  43.       else
  44.          x ||:= "<" || c || "> "
  45.    return x
  46. end
  47.