Xref: utzoo sci.electronics:16472 rec.ham-radio:28857 Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!uunet!sco!gorn!deeptht!spcecdt From: spcecdt@deeptht.UUCP (John DuBois) Newsgroups: sci.electronics,rec.ham-radio Subject: Re: Morse code program for PC .. here is Summary: XENIX Morse generator Message-ID: <119@deeptht.UUCP> Date: 25 Dec 90 10:17:53 GMT References: <1990Dec14.150715.4789@ssd.kodak.com> Reply-To: spcecdt@deeptht.santa-cruz.ca.us (John DuBois) Followup-To: rec.ham-radio Organization: The Armory Lines: 64 Here's an awk text-to-Morse translator that will work on SCO consoles... John DuBois spcecdt@deeptht.santa-cruz.ca.us : # Morse to ascii translator # John H. DuBois III 11/90 # Written for XENIX console; depends on SYSV tty modes (cr2) # and SCO ANSI set-beep-length escape code # Stuck at max ~8 wpm by shortest console beep & length of cr2 delay # save tty mode so it can be reset ttymode=`stty -g < /dev/tty` # reset tty mode if program aborted trap "stty $ttymode < /dev/tty" INT QUIT # set cr2 so that cr delays can be used for timing stty cr2 < /dev/tty # set bell to 1/(1487*840.3ns) Hz (800 Hz), 100 mS duration # note: bell is *not* reset at end of script, # since there's no way to tell what it was set to from a script echo -n "\033[=1487;1B" tr '[A-Z]' '[a-z]' | awk ' BEGIN { split("a.- b-... c-.-. d-.. e. f..-. g--. h.... i.. j.--- k-.- l.-.."\ " m-- n-. o--- p.--. q--.- r.-. s... t- u..- v...- w.-- x-..- y-.-- z--.."\ " ,--..-- ..-.-.- --...- =-...- /-..-. E.-.-."\ " 0----- 1.---- 2..--- 3...-- 4....- 5..... 6-.... 7--... 8---.. 9----.", Data," ") Delay = "\015" S["."] = "\07" Delay S["-"] = "\07\07\07" Delay Delay Char = Delay Delay Word = Char Char Char for (i in Data) { Letter = substr(Data[i],1,1) Morse = substr(Data[i],2) len = length(Morse); for (j = 1; j <= len; j++) L[Letter] = L[Letter] S[substr(Morse,j,1)] } L[" "] = Word L["\t"] = Word } { # translate entire line before outputting to minimize effects of # load on timing Line = "" len = length($0); for (i = 1; i <= len; i++) Line = Line L[substr($0,i,1)] Char Line = Line Word printf("%s",Line); } END { printf L["E"] } ' stty $ttymode < /dev/tty