编
编程傻子
Unregistered / Unconfirmed
GUEST, unregistred user!
ype
TMyData = packed record
w: packed array[0..2]of word;
dw: packed array[0..8]of dword;
end;
var
Form1: TForm1;
f:file of TMyData;
Data: TMyData;
implementation
{$R *.DFM}
procedure TForm1.ShowData;
begin
with Data do
memo1.Lines.Add(format('w1:%d,w2:%d,w3:%d,dw1:%d,dw2:%d,dw3:%d',[w[0],w[1],w[2],dw[0],dw[1],dw[2]]));
end;
//读
procedure TForm1.Button1Click(Sender: TObject);
var
NumRead:integer;
begin
//caption := inttostr(Sizeof(Data));
assignfile(f,'T0105.101');
Reset(f);
BlockRead(f,Data,Sizeof(Data),NumRead);
closefile(f);
ShowData;
end;
//写
procedure TForm1.Button2Click(Sender: TObject);
begin
Data.w[0] := 1;
Data.w[1] := 2;
Data.w[2] := 3;
Data.dw[0] := 4;
assignfile(f,'T0105.101');
ReWrite(f);
BlockWrite(f,Data,Sizeof(Data));
closefile(f);
end;
这段程序在调试的时候不出错,单独执行的时候在读的时候会弹出,closefile(f);//这里错
非法操作。不知何故
还有就是如果我要修改某一个参数应该怎样做.
谢谢
TMyData = packed record
w: packed array[0..2]of word;
dw: packed array[0..8]of dword;
end;
var
Form1: TForm1;
f:file of TMyData;
Data: TMyData;
implementation
{$R *.DFM}
procedure TForm1.ShowData;
begin
with Data do
memo1.Lines.Add(format('w1:%d,w2:%d,w3:%d,dw1:%d,dw2:%d,dw3:%d',[w[0],w[1],w[2],dw[0],dw[1],dw[2]]));
end;
//读
procedure TForm1.Button1Click(Sender: TObject);
var
NumRead:integer;
begin
//caption := inttostr(Sizeof(Data));
assignfile(f,'T0105.101');
Reset(f);
BlockRead(f,Data,Sizeof(Data),NumRead);
closefile(f);
ShowData;
end;
//写
procedure TForm1.Button2Click(Sender: TObject);
begin
Data.w[0] := 1;
Data.w[1] := 2;
Data.w[2] := 3;
Data.dw[0] := 4;
assignfile(f,'T0105.101');
ReWrite(f);
BlockWrite(f,Data,Sizeof(Data));
closefile(f);
end;
这段程序在调试的时候不出错,单独执行的时候在读的时候会弹出,closefile(f);//这里错
非法操作。不知何故
还有就是如果我要修改某一个参数应该怎样做.
谢谢