{$M 12000,0,655360}
uses bsd_unit,bsd_Objects,bsd_Strings;
var Form1:Forms;
SerialNumber,
SerialSystem,
UserSystem,
UserResult,
Dec,ActBase1,ActBase2,ActBase3
:TMaskEdit;
Conv1,Base1,Conv2,Base2,Base3
:Button;
Labels :Array [0..4] Of TLabel;
procedure ChangeBase1;
begin
Case ActBase1^.Text[1] Of
'2': ActBase1^.Text:='3';
'3': ActBase1^.Text:='4';
'4': ActBase1^.Text:='5';
'5': ActBase1^.Text:='6';
'6': ActBase1^.Text:='7';
'7': ActBase1^.Text:='8';
'8': ActBase1^.Text:='9';
'9': ActBase1^.Text:='16';
else ActBase1^.Text:='2';
End;
Form1.UpDateEdit(ActBase1);
Conv1^.Click;
end;
procedure ChangeBase2;
begin
Case ActBase2^.Text[1] Of
'2': begin
ActBase2^.Text:='8';
UserSystem^.Mask:='O'
end;
'8': begin
ActBase2^.Text:='10';
UserSystem^.Mask:='9'
end;
'1': if ActBase2^.Text[2]='0'
then begin
ActBase2^.Text:='16';
UserSystem^.Mask:='H'
end
else begin
ActBase2^.Text:='2';
UserSystem^.Mask:='B'
end
End;
Form1.UpDateEdit(ActBase2);
Form1.ClearEdit(UserSystem);
end;
procedure ChangeBase3;
begin
Case ActBase3^.Text[1] Of
'2': begin
ActBase3^.Text:='8';
UserResult^.Mask:='O'
end;
'8': begin
ActBase3^.Text:='10';
UserResult^.Mask:='9'
end;
'1': if ActBase3^.Text[2]='0'
then begin
ActBase3^.Text:='16';
UserResult^.Mask:='H'
end
else begin
ActBase3^.Text:='2';
UserResult^.Mask:='B'
end
End;
Form1.UpDateEdit(ActBase3);
Form1.ClearEdit(UserResult);
Conv2^.Click;
end;
procedure Convert1;
begin
SerialNumber^.Text:=DecToBase(StrToInt(Dec^.Text),StrToInt(ActBase1^.Text));
SerialSystem^.Text:=ASCII_Serial(SerialNumber^.Text,StrToInt(ActBase1^.Text));
Form1.UpDateEdit(SerialNumber);
Form1.UpDateEdit(SerialSystem);
end;
procedure HexBinCheck;
begin
{These checks only HEX & BIN Systems !, You Can Add Others}
if (Length(UserSystem^.Text)>4)and(ActBase2^.Text='16')
then MessageDlg(' Information !','^^ The result of this conversion '+
'will not be completed due to the used type restriction^^'+
'Try to feet a [4] maximum length like [FFFF]','$OK$')
else if (Length(UserSystem^.Text)>16)and(ActBase2^.Text='2')
then MessageDlg(' Information !','^^ The result of this conversion '+
'will not be completed due to the used type restriction^^'+
'Try to feet a [16] maximum length like [11..0111]','$OK$');
end;
procedure Convert2;
begin
HexBinCheck;
if ActBase2^.Text=ActBase3^.Text
then UserResult^.Text:=UserSystem^.Text
else
UserResult^.Text:=
ASCII_Serial(
DecToBase (
BaseToDec(StrToInt(ActBase2^.Text),UserSystem^.Text) , StrToInt(ActBase3^.Text)
) , StrToInt(ActBase3^.Text)
);
Form1.UpDateEdit(UserResult);
end;
procedure Form1_Obj;
begin With Form1 do BEGIN
InitLabel(Labels[0],5,26,clWhite,clGray,' The maximum HEX length is [4] like [FFFF] and so on for others..');
InitLabel(Labels[1],5,27,clWhite,clGray,' if you exceed the length of each system,');
InitLabel(Labels[2],5,28,clWhite,clGray,' the conversion will be cutted from the left of each one.');
InitLabel(Labels[3],5,29,clWhite,clGray,' this is about the restriction of the used type [WORD]');
InitLabel(Labels[4],28,7,clWhite,clGray,' Here you can enter the base manually,');
NewButton(Base1,35,45,10,10,True,clWhite,clWhite,clGray,True,'[B]ase',@ChangeBase1);
NewButton(Conv1,47,61,20,20,True,clWhite,clWhite,clGray,True,'[C]onversion',@Convert1);
NewButton(Base2,53,68,34,34,True,clWhite,clWhite,clGray,True,'From Base [1]',@ChangeBase2);
NewButton(Base3,53,68,39,39,True,clWhite,clWhite,clGray,True,'To Base [2]',@ChangeBase3);
NewButton(Conv2,13,31,43,43,True,clWhite,clWhite,clGray,True,'Conversion [3]',@Convert2);
InitEdit(Dec,'9',13,22,10,10,clGray,clBlack,clWhite,clBlack,'987','[D]ecimal',@Read_Edit);
InitEdit(ActBase1,'9',30,32,10,10,clGray,clBlack,clWhite,clBlack,'2','',@Read_Edit);
InitEdit(SerialNumber,'#',13,55,15,15,clGray,clBlack,clWhite,clBlack,'',' SerialNumber:',nil);
InitEdit(SerialSystem,'#',13,43,20,20,clGray,clBlack,clWhite,clBlack,'',' SerialSystem:',nil);
InitEdit(ActBase2,'*',48,50,34,34,clGray,clBlack,clWhite,clBlack,'16','',nil);
InitEdit(ActBase3,'*',48,50,39,39,clGray,clBlack,clWhite,clBlack,'2','',nil);
InitEdit(UserSystem,'H',13,45,34,34,clGray,clBlack,clWhite,clBlack,'A54F',' [E]nter Your System Here : ',@Read_Edit);
InitEdit(UserResult,'B',13,45,39,39,clGray,clBlack,clWhite,clBlack,'',' The Conversion Result : ',@Read_Edit);
With Form^ do BEGIN
FillStyle:=7;
clBk :=clRed;
clFace :=clGray;
EnableStatus := True;
Status := ' Try to feet the range of your appropriate conversion..';
Caption := ' System''s Conversion [Bin,Oct,Dec,Hex,..]';
END
END
end;
begin
Application.CreateForm(@Form1,@Form1_Obj);
Application.Execute(@Form1);
end.