Morse code: Difference between revisions

m
Line 1,321:
<lang>txt$ = "sos sos"
#
chars$[] = str_chars "abcdefghijklmnopqrstuvwxyz "
subr morse
mccode$[] = [ ".-" "-..." "-.-." "-.." "." "..-." "--." "...." ".---." ".---" "-.-" ".-.." "--" "-." "---" ".--." "--.-" ".-." "..." "-" "..-" "...-" ".--" "-..-" "-.--" "--.." " " ]
j = 0
#
while j < len abc$[] and abc$[j] <> c$
func morse ch$ . .
j += 1
while jind < len abcchars$[] and abcchars$[jind] <> cch$
jind += 1
.
if jind < len abcchars$[]
mwrite ch$ =& mc$[j]" "
sleep 0.4
else
mfor c$ =in "x"str_chars code$[ind]
write mc$[j]
.
write if c$ &= " ."
play_sound [ 440 0.62 ]
sleep 0.4
sleep 0.84
m$[] = str_chars m$
for j range len melif c$[] = "-"
play_sound [ 880440 0.6 ]
write m$[j]
if m$[j] = " sleep 0."8
play_soundelif [c$ 440= 0.2" ]"
sleep 0.48
elif m$[j] = "-".
play_sound [ 440 0.6 ]
sleep 0.8
elif m$[j] = " "
sleep 0.8
else
# error
play_sound [ 880 0.6 ]
sleep 0.8
.
.
print ""
.
abcfor ch$[] =in str_chars "abcdefghijklmnopqrstuvwxyz "txt$
call morse ch$
mc$[] = [ ".-" "-..." "-.-." "-.." "." "..-." "--." "...." ".---" ".---" "-.-" ".-.." "--" "-." "---" ".--." "--.-" ".-." "..." "-" "..-" "...-" ".--" "-..-" "-.--" "--.." " " ]
txt$[] = str_chars txt$
for i range len txt$[]
c$ = txt$[i]
call morse
.</lang>
 
2,033

edits