unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, Buttons;//, CommInt;
type
TForm1 = class(TForm)
Memo1: TMemo;
Edit1: TEdit;
Label1: TLabel;
Memo2: TMemo;
Label2: TLabel;
Label4: TLabel;
Label5: TLabel;
Timer1: TTimer;
Button2: TButton;
Button1: TButton;
Label3: TLabel;
Label6: TLabel;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function translate(str:string):string; //16进制数的点阵显示解释
var
st:string;
num:integer;
trans:string;
begin
st:=str;
trans:='';
for num:=1 to 6 do
begin
case st[num] of
'0':trans:=trans+' ';
'1':trans:=trans+' 11';
'2':trans:=trans+' 11 ';
'3':trans:=trans+' 1111';
'4':trans:=trans+' 11 ';
'5':trans:=trans+' 11 11';
'6':trans:=trans+' 1111 ';
'7':trans:=trans+' 111111';
'8':trans:=trans+'11 ';
'9':trans:=trans+'11 11';
'A':trans:=trans+'11 11 ';
'B':trans:=trans+'11 1111';
'C':trans:=trans+'1111 ';
'D':trans:=trans+'1111 11';
'E':trans:=trans+'111111 ';
'F':trans:=trans+'11111111';
end;
end;
translate:=trans;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
hzk24:file of char
i:array[1..72] of char;
k,s,sss,stemp:string;
count,j:longint;
l,n:integer;
i1:array[1..72] of char;
col,row,offset:integer;
pp:char;
mask,colmask:char;
ttt:integer;
begin //横排显示
assignfile(hzk24,'hzk24s');
FileMode:=0;//read only
reset(hzk24);
memo1.Text:='';
memo2.text:='';
sss:='';
k:='';
for l:=1 to length(edit1.text) do
begin
{k:=copy(edit1.text,(length(edit1.text) div 2),2);}
k:=k+edit1.text[l];
if (l mod 2=0) then
begin
j:=((ord(k[1])-161-15)*94+(ord(k[2])-161))*72;//在字库的首地址(24点阵)
label3.Caption:=inttostr(ord(k[1]));
label6.Caption:=inttostr(ord(k[2]));
seek(hzk24,j);
n:=1;
s:='';
for count:=1 to 72 do
begin
read(hzk24,i[n]);
stemp:=inttohex(ord(i[n]),2)+'H';
if ((n mod 8)<>0 )then stemp:=stemp+',';
if stemp[1]>'9' then stemp:='0'+stemp;
sss:=sss+stemp;
if n mod 3=0 then sss:=sss+chr(13)+chr(10);
n:=n+1;
end;
//显示一个汉字
begin
//将数据变换
colmask:=char(128);
for col:=1 to 24 do
begin
for row:=1 to 3 do
begin
mask:=char(128);
pp:=char(0);
for offset:=0 to 7 do
begin
ttt:=(((row-1)*8+offset)*3+((col-1) div 8))+1;
if (integer(i[ttt]) and integer(colmask))<>0 then
pp:=char(integer(pp) or integer(mask));
mask:=char(integer(mask) shr 1);
end;
i1[(col-1)*3+row]:=pp;
end;
if (col mod 8)=0 then
colmask:=char(128)
else
colmask:=char(integer(colmask) div 2);
end;
end;//for count:=1 to 72 do
sss:=sss+chr(13)+chr(10);
s:='';
for count:=1 to 72 do
begin
stemp:=inttohex(ord(i1[count]),2)+'H';
if ((count mod 8)<>0 )then stemp:=stemp+',';
if stemp[1]>'9' then stemp:='0'+stemp;
sss:=sss+stemp;
if count mod 3=0 then sss:=sss+chr(13)+chr(10);
s:=s+inttohex(ord(i1[count]),2);
if ((count) mod 3=0) then
begin
memo1.Lines.Add(' '+translate(s));
s:='';
end;
end;
memo2.text:=sss;
sss:=sss+chr(13)+chr(10);
k:='';
end;//if (l mod 2=0) then
end;//for l:=1 to length(edit1.text) do
system.Close(hzk24);
end;//function
procedure TForm1.Timer1Timer(Sender: TObject); //显示日期时间
begin
label4.caption:= formatdatetime('yyyy-mm-dd',date);
label5.caption:= formatdatetime('hh:mm:ss',time);
end;
procedure TForm1.Button2Click(Sender: TObject); //结束
begin
application.Terminate;
end;
end.