1. Home
  2. Computing & Technology
  3. Delphi Programming

Morse Delphi Box
Fancy Delphi Application Contest Entry #1 by "JoshyFun"

By Zarko Gajic, About.com

Morse Delphi Box - Fancy Delphi Application Contest Entry #1

Morse Delphi Box - Fancy Delphi Application Contest Entry #1

Morse code is a method of coding messages into long and short beeps, often transmitted using continuous wave.

This is the first entry to the Fancy Delphi Application Contest

Rate this FDAC Entry!

Delphi Morse Box

This little fabulous (useless) application will play Morse codes as you type character into a console-looking window.

First, letters are "turned" into morse codes using an array of strings:

var MorseArray: array ['a'..'z'] of string;

...

procedure TfrmMorseBox.FormCreate(Sender: TObject) ;
begin
  MorseArray['a']:='.-';
  MorseArray['b']:='-...';
...
  MorseArray['z']:='--..';
end;
Next, as you type into the windows, the OnKeyPress event plays morse tones through your computer speakerphone:
procedure TfrmMorseBox.memoMorseKeyPress(Sender: TObject; var Key: Char) ;
var
  s: String;
  Morse: String;
  j: integer;
begin
  s:=lowercase(Key) ;
  if (s>='a') and (s<='z') Then begin
    Morse:=MorseArray[s[1]];
    for j := 1 to Length(Morse) do begin
      if Morse[j]='.' Then begin
        Windows.Beep(1206,MORSE_UNIT+random(MORSE_GROOVE))
      end else begin
        Windows.Beep(1200,MORSE_UNIT*3+random(MORSE_GROOVE*3))
      end;
      Sleep(MORSE_UNIT*3+random(MORSE_GROOVE*3)) ;
    end;
  end else begin
    if s=' ' Then begin
      Sleep(MORSE_UNIT*7+random(MORSE_GROOVE*7)) ;
    end;
  end;
end;
Yes! Morse codes using Beep. That simple!!

Morse box was submitted by "JoshyFun".

Do you have a FDA(C)? Submit your Delphi code to the Fancy Delphi Application Contest.

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Source Code Projects
  5. Morse Delphi Box - Fancy Delphi Application Contest Entry #1

©2009 About.com, a part of The New York Times Company.

All rights reserved.