unit1.pas

来自「这是一个股票盘后数据分析系统基础底层,已经实现了基本的K线图的重现,RIS线,均」· PAS 代码 · 共 81 行

PAS
81
字号
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 + =
减小字号Ctrl + -
显示快捷键?