Morse code: Difference between revisions

Content added Content deleted
Line 1,463: Line 1,463:
code$[] = [ ".-" "-..." "-.-." "-.." "." "..-." "--." "...." ".." ".---" "-.-" ".-.." "--" "-." "---" ".--." "--.-" ".-." "..." "-" "..-" "...-" ".--" "-..-" "-.--" "--.." " " ]
code$[] = [ ".-" "-..." "-.-." "-.." "." "..-." "--." "...." ".." ".---" "-.-" ".-.." "--" "-." "---" ".--." "--.-" ".-." "..." "-" "..-" "...-" ".--" "-..-" "-.--" "--.." " " ]
#
#
func morse ch$ . .
proc morse ch$ . .
ind = 1
ind = 1
while ind <= len chars$[] and chars$[ind] <> ch$
while ind <= len chars$[] and chars$[ind] <> ch$
ind += 1
ind += 1
.
.
if ind <= len chars$[]
if ind <= len chars$[]
write ch$ & " "
write ch$ & " "
sleep 0.4
sleep 0.4
for c$ in strchars code$[ind]
for c$ in strchars code$[ind]
write c$
write c$
if c$ = "."
if c$ = "."
sound [ 440 0.2 ]
sound [ 440 0.2 ]
sleep 0.4
sleep 0.4
elif c$ = "-"
elif c$ = "-"
sound [ 440 0.6 ]
sound [ 440 0.6 ]
sleep 0.8
sleep 0.8
elif c$ = " "
elif c$ = " "
sleep 0.8
sleep 0.8
.
.
.
.
print ""
print ""
.
.
.
.
for ch$ in strchars txt$
for ch$ in strchars txt$
call morse ch$
call morse ch$
.
.
</syntaxhighlight>
</syntaxhighlight>