SRL Archive - Other Scripts

HTS Programming 2 / Morse2ABC


mastaraymond

2009-05-31 03:42:30

Aya, I wasted my time on copying morse code so I decided I would post this script :D

program loveu;
function ABC2Morse(abc : string) : string;
var
MorseArr : TStringArray;
ABCString : String;
I : integer;
begin;
ABCString := 'abcdefghijklmnopqrstuvwxyz0123456789 ';
abc := lowercase(abc);
MorseArr := ['.-','-...','-.-.','-..','.','..-.','--.','....','..','.---','-.-','.-..','--','-.','---','.--.','--.-','.-.',
'...','-','..-','...-','.--','-..-','-.--','--..','-----','.----','..---','...--','....-','.....','-....','--...','---..','----.','/'];
For i := 1 to length(AbC) do
if pos(abc[i],ABCString) > 0 then
result := result + MorseArr[Pos(Abc[i],ABCString)-1] + ' '
else
Writeln('WTF IS ' + ABC[i] + ' IN MORSE CODE!!?');
SetLength(result,length(result)-1);
end;
function Morse2ABC(morse : string) : string;
var
x : TStringList;
i : integer;
begin;
x := TStringList.create;
x.DelimitedText := Replace(morse,'/','/ ');
x.Delimiter := ' ';
for i := 0 to x.count - 1 do
case x.strings[i] of
'/' : result := result + ' ';
'.-' : result := result + 'a';
'-...' : result := result + 'b';
'-.-.' : result := result + 'c';
'-..' : result := result + 'd';
'.' : result := result + 'e';
'..-.' : result := result + 'f';
'--.' : result := result + 'g';
'....' : result := result + 'h';
'..' : result := result + 'i';
'.---' : result := result + 'j';
'-.-' : result := result + 'k';
'.-..' : result := result + 'l';
'--' : result := result + 'm';
'-.' : result := result + 'n';
'---' : result := result + 'o';
'.--.' : result := result + 'p';
'--.-' : result := result + 'q';
'.-.' : result := result + 'r';
'...' : result := result + 's';
'-' : result := result + 't';
'..-' : result := result + 'u';
'...-' : result := result + 'v';
'.--' : result := result + 'w';
'-..-' : result := result + 'x';
'-.--' : result := result + 'y';
'--..' : result := result + 'z';
'-----' : result := result + '0';
'.----' : result := result + '1';
'..---' : result := result + '2';
'...--' : result := result + '3';
'....-' : result := result + '4';
'.....' : result := result + '5';
'-....' : result := result + '6';
'--...' : result := result + '7';
'---..' : result := result + '8';
'----.' : result := result + '9';
else
Writeln('ERRORD @ ' + x.strings[i]);
end;
end;
var
x,y,realx,cornerx,cornery: integer;
LastX : integer;
Str : String;
Morse : string;
begin
Writeln('Morsing -> Raymond is tha uber 1091290');
Morse := ABC2Morse('Raymond is tha uber 1091290');
Writeln('Morsed: ' + Morse);
Writeln('Reversed: ' + Uppercase(morse2abc(morse)));
Lastx := 0;
realx := -1;
if not FindColor(cornerx,cornery,0,0,300,500,500) then
writeln('Didn''t find the box');
Writeln('(' + inttostr(cornerx) + ',' + inttostr(cornery) + ')');
for y := cornery to cornery + 29 do
begin;
for x := cornerx to cornerx + 99 do
begin;
inc(realx);
if GetColor(x,y) = clwhite then
begin;
Str := Str + chr(realx-lastx);
Lastx := realx;
end;
end;
end;
Writeln(str);
Writeln(uppercase(Morse2ABC(str)));
end.

Dynamite

2009-05-31 03:47:11

lol you have wayyy to much time lol.

T~M

Harry

2009-05-31 04:00:45

So that's what Raym0nd` was doing in Rome instead of getting us pictures :(

mastaraymond

2009-05-31 13:54:35

From: The Man
lol you have wayyy to much time lol.

T~M

Took me 40 mins max :-(

EvilChicken!

2009-05-31 14:00:59

xD

Now show one situation where this could be useful in SCAR.

Floor66

2009-05-31 14:03:16

Make ABC2Morse too? x[]

mastaraymond

2009-05-31 14:10:53

From: EvilChicken!
xD

Now show one situation where this could be useful in SCAR.

HTS Programming challenge 2!! <—

And nah, not going to make a reverse.. Way to much work.

mastaraymond

2009-05-31 14:24:01

From: mastaraymond
HTS Programming challenge 2!! <—

And nah, not going to make a reverse.. Way to much work.

I lied, I made ABC2Morse <– I has way to much free time on my hands.

Floor66

2009-05-31 14:24:42

Post! :D

mastaraymond

2009-05-31 14:25:15

From: Floor66
Post! :D

Mainpost :rolleyes: