📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TStockData = packed record
date: integer;
OpenValue: integer;
HighValue: integer;
LowValue: integer;
CloseValue: integer;
Amount: integer;
DealVol: integer;
Reservation: integer;
end;
type
TForm1 = class(TForm)
Button1: TButton;
StringGrid1: TStringGrid;
Memo1: TMemo;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1 : TForm1;
myType : array of TStockData;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
DataFile: file;
Data : integer;
Count : integer;
I : integer;
begin
Count := 0;
if OpenDialog1.Execute then
begin
try
AssignFile(DataFile, OpenDialog1.FileName);
Reset(DataFile, 1);
Count := Round(FileSize(DataFile) / sizeof(integer) / 8);
setlength(myType, Count);
I := 0;
while not Eof(DataFile) do
begin
BlockRead(DataFile, myType[I].date, sizeof(Data));
BlockRead(DataFile, myType[I].OpenValue, sizeof(Data));
BlockRead(DataFile, myType[I].HighValue, sizeof(Data));
BlockRead(DataFile, myType[I].LowValue, sizeof(Data));
BlockRead(DataFile, myType[I].CloseValue, sizeof(Data));
BlockRead(DataFile, myType[I].Amount, sizeof(Data));
BlockRead(DataFile, myType[I].DealVol, sizeof(Data));
BlockRead(DataFile, myType[I].Reservation, sizeof(Data));
inc(I);
Memo1.Lines.Add(inttostr(myType[I].date) + ' ' + inttostr(myType[I].OpenValue) + ' ' + inttostr(myType[I].CloseValue));
end; //while
CloseFile(DataFile);
//显示该数据
except
MessageDlg('文件读写错误,请重试!', mtInformation, [mbOk], 0);
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -