procedure TForm1.Button1Click(Sender: TObject);
var
wFile:TextFile;
wFileName,s,t:String;
i:Integer;
begin
s:=Edit1.Text;
t:=Edit2.Text;
if length(s)=0 then
begin
showmessage('Please input your string');
exit;
end;
if length(t)=0 then
begin
showmessage('请输入变量名');
exit;
end;
t:=Edit2.Text;
wFileName:= 'ByTeCrypt.txt';
AssignFile(wFile, wFileName);
Rewrite(wFile);
Writeln(wFile,'var');
Writeln(wFile,' '+t+':array[1..'+IntToStr(Length(s))+'] of char;'); //生成定义t:array[1..?] of char
Writeln(wFile,'begin');
for i:=1 to Length(s) do
begin
Writeln(wFile, ' '+t+'['+IntToStr(i)+']:=Char('+IntToStr(Ord(s[i]))+');'); //生成语句t[?]:=Char(?);
end;
Writeln(wFile,' Showmessage('+t+');');
Writeln(wFile,'end;');
CloseFile(wFile);
showmessage('执行完毕,请查看同目录下ByTeCrypt.txt文件!');