52 lines
1.7 KiB
Plaintext
52 lines
1.7 KiB
Plaintext
/* Sound Morse code via the PC buzzer. June 2011 */
|
|
MORSE: procedure options (main);
|
|
declare (i, j) fixed binary;
|
|
declare buzz character (1) static initial ('07'x);
|
|
declare text character (100) varying,
|
|
c character (1);
|
|
declare alphabet character (36) static initial (
|
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789');
|
|
declare morse_character character(5) varying;
|
|
declare morse_codes(36) character(5) varying static initial (
|
|
/* Letters A-Z */
|
|
'.-', '-...', '-.-.', '-..', '.',
|
|
'..-.', '--.', '....', '..', '.---',
|
|
'-.-', '.-..', '--', '-.', '---',
|
|
'--.-', '--.-', '.-.', '...', '-',
|
|
'..-', '...-', '.--', '-..-', '-.--',
|
|
'--..',
|
|
/* Digits 0-9 */
|
|
'-----', '.----', '..---', '...--', '....-',
|
|
'.....', '-....', '--...', '---..', '----.' );
|
|
|
|
put skip list ('Please type the text to be transmitted:');
|
|
get edit (text) (L);
|
|
|
|
do i = 1 to length (text);
|
|
c = substr(text, i, 1);
|
|
j = index(alphabet, uppercase(c));
|
|
if j > 0 then
|
|
do;
|
|
morse_character = morse_codes(j);
|
|
put skip list (morse_character); /* Display the Morse. */
|
|
call send_morse (morse_character);
|
|
end;
|
|
end;
|
|
|
|
send_morse: procedure (morse_character);
|
|
declare morse_character character(*) varying;
|
|
declare i fixed binary;
|
|
|
|
do i = 1 to length(morse_character);
|
|
if substr(morse_character, 1, 1) = '-' then
|
|
put skip edit (buzz, ' ', buzz) (a(1), A, skip, a(1));
|
|
else
|
|
put skip edit (buzz, ' ') (a(1));
|
|
delay (1000); /* Delay one period. */
|
|
end;
|
|
delay (1000);
|
|
/* Making a delay of 2 periods after each English letter. */
|
|
end send_morse;
|
|
|
|
END MORSE;
|