home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1999 August
/
Chip_1999-08_cd.bin
/
tema
/
Ozogan
/
RUNTIME
/
APLIKACE.EXE
/
MORSE.KL3
< prev
next >
Wrap
Text File
|
1999-06-19
|
8KB
|
204 lines
Program morse;
{**************************************}
{ Program pro v²poΦet plochy a obvodu }
{ Autor: Petr Ozogßn, 19.6.1999 }
{**************************************}
Function TxtToMor(txt: char): String;
begin
txt:= UpperCase(txt); Result := txt+'/';
if txt = 'A' then Result := '.-/'; if txt = 'B' then Result := '-.../';
if txt = 'C' then Result := '-.-./'; if txt = 'D' then Result := '-../';
if txt = 'E' then Result := './'; if txt = 'F' then Result := '..-./';
if txt = 'G' then Result := '--./'; if txt = 'H' then Result := '..../';
if txt = 'I' then Result := '../'; if txt = 'J' then Result := '.---/';
if txt = 'K' then Result := '-.-/'; if txt = 'L' then Result := '.-../';
if txt = 'M' then Result := '--/'; if txt = 'N' then Result := '-./';
if txt = 'O' then Result := '---/'; if txt = 'P' then Result := '.--./';
if txt = 'Q' then Result := '--.-/'; if txt = 'R' then Result := '.-./';
if txt = 'S' then Result := '.../'; if txt = 'T' then Result := '-/';
if txt = 'U' then Result := '..-/'; if txt = 'V' then Result := '...-/';
if txt = 'W' then Result := '.--/'; if txt = 'X' then Result := '-..-/';
if txt = 'Y' then Result := '-.--/'; if txt = 'Z' then Result := '--../';
if txt = '1' then Result := '.----/'; if txt = '2' then Result := '..---/';
if txt = '3' then Result := '...--/'; if txt = '4' then Result := '....-/';
if txt = '5' then Result := '...../'; if txt = '6' then Result := '-..../';
if txt = '7' then Result := '--.../'; if txt = '8' then Result := '---../';
if txt = '9' then Result := '----./'; if txt = '0' then Result := '-----/';
if txt = ' ' then Result := '/'; if txt = '"' then Result := '-...-/';
if txt = '.' then Result := '....../'; if txt = '?' then Result := '..--../';
if txt = ',' then Result := '.-.-.-/'; if txt = ':' then Result := '---.../';
if txt = '!' then Result := '--..--/'; if txt = '-' then Result := '-....-/';
{nßsledujφcφ znak je asi dopln∞n chybn∞, jinak by to ale nefungovalo}
if txt = '/' then Result := '------/';
end;
Function MorToTxt(mor: String): char;
begin
Result := '/'+Copy(MOR, 1, Length(MOR)-1)+'/';
if mor = '.-/' then Result := 'A'; if mor = '-.../' then Result := 'B';
if mor = '-.-./' then Result := 'C'; if mor = '-../' then Result := 'D';
if mor = './' then Result := 'E'; if mor = '..-./' then Result := 'F';
if mor = '--./' then Result := 'G'; if mor = '..../' then Result := 'H';
if mor = '../' then Result := 'I'; if mor = '.---/' then Result := 'J';
if mor = '-.-/' then Result := 'K'; if mor = '.-../' then Result := 'L';
if mor = '--/' then Result := 'M'; if mor = '-./' then Result := 'N';
if mor = '---/' then Result := 'O'; if mor = '.--./' then Result := 'P';
if mor = '--.-/' then Result := 'Q'; if mor = '.-./' then Result := 'R';
if mor = '.../' then Result := 'S'; if mor = '-/' then Result := 'T';
if mor = '..-/' then Result := 'U'; if mor = '...-/' then Result := 'V';
if mor = '.--/' then Result := 'W'; if mor = '-..-/' then Result := 'X';
if mor = '-.--/' then Result := 'Y'; if mor = '--../' then Result := 'Z';
if mor = '.----/' then Result := '1'; if mor = '..---/' then Result := '2';
if mor = '...--/' then Result := '3'; if mor = '....-/' then Result := '4';
if mor = '...../' then Result := '5'; if mor = '-..../' then Result := '6';
if mor = '--.../' then Result := '7'; if mor = '---../' then Result := '8';
if mor = '----./' then Result := '9'; if mor = '-----/' then Result := '0';
if mor = '/' then Result := ' '; if mor = '///' then Result := '.';
if mor = '....../' then Result := '.'; if mor = '..--../' then Result := '?';
if mor = '.-.-.-/' then Result := ','; if mor = '---.../' then Result := ':';
if mor = '--..--/' then Result := '!'; if mor = '-....-/' then Result := '-';
if mor = '-...-/' then Result := '"';
{nßsledujφcφ znak je asi dopln∞n chybn∞, jinak by to ale nefungovalo}
if mor = '------/' then Result := '/';
end;
procedure TForm.ButtonToMORClick(Sender: TObject);
Var x, y: Integer; RadTxt, RadMor, Bak, Pismeno: String;
begin
Bak := '';
RadMor := '';
MemoMOR.Clear;
for x:= 0 to MemoTXT.Lines.Count-1 do
begin
RadTxt:= CsWinToAsc(MemoTXT.Lines[x]);
for y:= 1 to Length(RadTxt) do
begin
Pismeno := Copy(RadTxt, y, 1);
if (Bak+Pismeno<>' ') then RadMor:= RadMor + TxtToMor(Pismeno);
if Length(RadMor)>65 then
begin
MemoMOR.Lines.Add(RadMor); RadMor := '';
end;
Bak := Pismeno;
end;
RadMor:= RadMor + '/';
end;
MemoMOR.Lines.Add(RadMor);
MemoMOR.SelStart := 1;
end;
procedure TForm.ButtonToTXTClick(Sender: TObject);
Var poz, x, y: Integer; RadTxt, Pismeno, RadMor: String;
begin
RadTxt := '';
MemoTXT.Clear;
for x:= 0 to MemoMOR.Lines.Count-1 do
begin
RadMor:= MemoMor.Lines[x];
if Pos('/', RadMor) = 0 then RadMor := RadMor + '/';
While Length(RadMor) > 0 do
begin
Poz := Pos('/', RadMor);
if Poz = 0 then RadMor := '';
Pismeno := Copy(RadMor, 1, Poz);
RadTxt:= RadTxt + MorToTxt(Pismeno);
if Length(RadTxt)>65 then
begin
MemoTXT.Lines.Add(RadTxt); RadTxt := '';
end;
RadMor := Copy(RadMor, Poz+1, Length(RadMor)-Poz);
end;
end;
MemoTXT.Lines.Add(RadTxt);
end;
procedure TForm.ButtonLoadTXTClick(Sender: TObject);
begin
OpenDialog.DefaultExt := 'TXT';
OpenDialog.Filter := 'Texty *.txt|*.txt';
If OpenDialog.Execute then MemoTXT.Lines.LoadFromFile(OpenDialog.FileName);
end;
procedure TForm.ButtonLoadMORClick(Sender: TObject);
begin
OpenDialog.DefaultExt := 'MOR';
OpenDialog.Filter := 'Morseovka *.mor|*.mor';
If OpenDialog.Execute then MemoMOR.Lines.LoadFromFile(OpenDialog.FileName);
end;
procedure TForm.ButtonSaveTXTClick(Sender: TObject);
begin
SaveDialog.DefaultExt := 'TXT';
SaveDialog.Filter := 'Texty *.txt|*.txt';
If SaveDialog.Execute then MemoTXT.Lines.SaveToFile(SaveDialog.FileName);
end;
procedure TForm.ButtonSaveMORClick(Sender: TObject);
begin
SaveDialog.DefaultExt := 'MOR';
SaveDialog.Filter := 'Morseovka *.mor|*.mor';
If SaveDialog.Execute then MemoMOR.Lines.SaveToFile(SaveDialog.FileName);
end;
procedure TForm.ButtonClearTXTClick(Sender: TObject);
begin
MemoTXT.Clear;
end;
procedure TForm.ButtonClearMORClick(Sender: TObject);
begin
MemoMOR.Clear;
end;
procedure TForm.ButtonCloseClick(Sender: TObject);
begin
Form.Close;
end;
procedure TForm.FormResize(Sender: TObject);
begin
ButtonClose.Left := Form.Width - 115;
Panel2.Height := (Form.ClientHeight-50)/2;
end;
procedure TForm.ButtonPrintTXTClick(Sender: TObject);
Var x: Integer; RadTxt : String;
begin
if MessageDlg('Opravdu vytisknout text ?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
ConsoleClear;
ConsoleHide;
for x:= 0 to MemoTXT.Lines.Count-1 do
begin
RadTxt:= MemoTXT.Lines[x];
Writeln(RadTxt);
end;
ConsolePrint;
end;
end;
procedure TForm.ButtonPrintMORClick(Sender: TObject);
Var x: Integer; RadMor : String;
begin
if MessageDlg('Opravdu vytisknout morseovku ?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
ConsoleClear;
ConsoleHide;
for x:= 0 to MemoMOR.Lines.Count-1 do
begin
RadMor:= MemoMOR.Lines[x];
Writeln(RadMor);
end;
ConsolePrint;
end;
end;
end.