Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Form1: TForm1;
t_biner,t_heksa,t_heksa1,t_heksa2,t_biner2:string;
t_desimal,t_temp:integer;
implementation
{$R *.dfm}
procedure kebiner1 (t_Hexa:string);
var
data:string;
begin
data:=t_hexa;
if data ='0' then data :='000';
if data ='1' then data :='001';
if data ='2' then data :='010';
if data ='3' then data :='011';
if data ='4' then data :='100';
if data ='5' then data :='101';
if data ='6' then data :='110';
if data ='7' then data :='111';
if data ='8' then data :='1000';
t_biner:=data;
end;
//...........................//
procedure keheksa(data:string);
var
temp:string;
begin
temp:=data;
if temp = '0000' then temp :='0';
if temp = '0001' then temp :='1';
if temp = '0010' then temp :='2';
if temp = '0011' then temp :='3';
if temp = '0100' then temp :='4';
if temp = '0101' then temp :='5';
if temp = '0110' then temp :='6';
if temp = '0111' then temp :='7';
if temp = '1000' then temp :='8';
if temp = '1001' then temp :='9';
if temp = '1010' then temp :='A';
if temp = '1011' then temp :='B';
if temp = '1100' then temp :='C';
if temp = '1101' then temp :='D';
if temp = '1110' then temp :='E';
if temp = '1111' then temp :='F';
t_heksa:=temp+t_heksa;
end;
b:=0; c:=0;
jumlah_kata:=inttohex(length(data),1);
if length(jumlah_kata) <2 then jumlah_kata:='0'+jumlah_kata;
pesan:=data;
for a:=length(pesan) downto 1 do
begin
hexa:=inttohex(ord(pesan[a]),2);
kebiner1(hexa[1]);
kebiner2(hexa[2]);
temp:=temp + t_biner;
end;
if length(temp)mod 8<>0 then
begin
b:=length(pesan);
if b>8 then b:=b mod 8;
for a:=1 to b do
begin
temp:='0'+temp;
end;
end;
b:=0; temp2:=''; hexa:='';
for a:=length(temp) downto 1 do
begin
temp2:=temp[a]+temp2;
inc(b);
if b>=4 then
begin
b:=0;
keheksa(temp2);
inc(c);
temp2:='';
if c>=2 then
begin
hexa:=hexa+t_heksa;
c:=0;
t_heksa:='';
end;
end;
end;
form1.Memo2.Text:=jumlah_kata+hexa;
end;
//................................................//
//
function HexToDec(Str: string): Integer;
var
i, M: Integer;
begin
Result:=0;
M:=1;
Str:=AnsiUpperCase(Str);
for i:=Length(Str) downto 1 do
begin
case Str[i] of
'1'..'9': Result:=Result+(Ord(Str[i])-Ord('0'))*M;
'A'..'F': Result:=Result+(Ord(Str[i])-Ord('A')+10)*M;
end;
M:=M shl 4;
end;
end;
//...............................................//
procedure sms_center_1(data:string);
var
x_sms,nomer,temp:string;
n,q,b,a,jumlah_pasangan,z,x:integer;
begin
b:=StrToInt(data[1]+data[2]);
q:=b*2+2;
Delete(data,1,4);
a:=1;
nomer:=data;
temp:=data;
z:=length(data);
while(a<=Length(data)) do
begin
nomer[a+1]:=temp[a];
nomer[a]:=temp[a+1];
a:=a+2;
end;
Form1.Edit5.Text:=nomer;
end;
//.................................//
procedure nomor_penerima_1(data:string);
var
x_sms,nomer,temp,b:string;
n,q,a,jumlah_pasangan,z,x:integer;
begin
Delete(data,1,4);
a:=1;
nomer:=data;
temp:=data;
z:=length(data);
while(a<=Length(data)) do
begin
nomer[a+1]:=temp[a];
nomer[a]:=temp[a+1];
a:=a+2;
end;
Form1.Edit6.Text:=nomer;
end;
//.................................................................//
procedure move(data:string);
var
o,x_sms,nomer,y,j,f,temp,u:string;
c,l,n,q,b,a,z,x,k,jumlah_pasangan:integer;
begin
c:=length(form1.Edit9.Text);
b:=StrToInt(data[1]+data[2]);
q:=b*2+2;
z:=q+5;
k:=z+1;
y:=data[z]+data[k];
o:=IntToStr(HexToDec(y));
x:=StrToInt(o)+z+3;
l:=x+7;
for n:=1 to q do
begin
Form1.Edit7.SelText:=data[n];
end;
for n:=z to x do
begin
Form1.Edit8.SelText:=data[n];
end;
for n:=l to c do
begin
Form1.Edit14.SelText:=data[n];
end;
end;
function HexToBin(HexStr: string): string;
const
BinArray: array[0..15, 0..1] of string =
(('0000', '0'), ('0001', '1'), ('0010', '2'), ('0011', '3'),
('0100', '4'), ('0101', '5'), ('0110', '6'), ('0111', '7'),
('1000', '8'), ('1001', '9'), ('1010', 'A'), ('1011', 'B'),
('1100', 'C'), ('1101', 'D'), ('1110', 'E'), ('1111', 'F'));
HexAlpha: set of char = ['0'..'9', 'A'..'F'];
var
i, j: Integer;
begin
Result:='';
HexStr:=AnsiUpperCase(HexStr);
for i:=1 to Length(HexStr) do
if HexStr[i] in HexAlpha then
begin
for j:=1 to 16 do
if HexStr[i]=BinArray[j-1, 1] then
Result:=Result+BinArray[j-1, 0];
end
else
end;
procedure bintext(pdu:string);
var
data,hasil,temp,temp2,temp3,biner:string;
desimal,jumlah_karakter,jumlah_ascii7,dummy_bit,a,b,c,d,i:integer;
begin
data:=copy(pdu, 3, length(pdu));
temp:=data;
c:=1;
d:=0;
while(c<=length(data)) do
begin
data[c+1]:=temp[length(data)-d];
data[c]:=temp[length(data)-(d+1)];
c:=c+2;
d:=d+2;
end;
for i:=1 to length(data) do
begin
kebiner2(data[i]);
biner:=biner + t_biner2;
end;
dummy_bit:=length(biner) mod 7;
delete(biner, 1, dummy_bit);
jumlah_ascii7:=length(biner) div 7;
c:=0;
d:=1;
while (c<jumlah_ascii7) do
begin
temp:=copy(biner, d, 7);
temp2:=copy(temp, 1, 3);
keheksa1(temp2);
temp3:=copy(temp, 4, 4);
keheksa2(temp3);
kedesimal(t_heksa1);
a:=t_desimal;
kedesimal(t_heksa2);
b:=t_desimal;
desimal:=(16*a)+b;
hasil:=hasil + chr(desimal);
d:=d+7;
c:=c+1;
end;
temp:=hasil;
c:=1;
d:=0;
while(c<=length(hasil)) do
begin
hasil[c]:=temp[length(hasil)-d];
c:=c+1;
d:=d+1;
end;
Form1.memo5.Text:=hasil;
Form1.Memo4.Text:='SMS Center: '+form1.Edit5.Text+' No Penerima:
'+form1.Edit6.Text+' Isi Pesan: '+Hasil;
t_heksa:='';
t_biner:='';
end;
edit2.Clear;
edit4.Clear;
memo1.Clear;
memo2.Clear;
Edit9.Clear;
end;
edit5.Clear;
Edit6.Clear;
Edit7.Clear;
Edit8.Clear;
Edit14.Clear;
Memo5.Clear;
Memo4.Clear;
end;
end.