unit UnitDataMng;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
16进制字符串转16进制数组
  Dialogs, DB, ADODB, StdCtrls, ExtCtrls, ComCtrls, Mask, DBCtrls, ComObj,
  Menus, CheckLst, Grids, ZAbstractRODataset, ZDataset, ZAbstractDataset,
  FileCtrl, ShellCtrls;
type
  TFormDataMng = class(TForm)
    Sb1: TStatusBar;
    Button1: TButton;
    Memo1: TMemo;
    Button2: TButton;
    Button3: TButton;
    Memo2: TMemo;
    Button4: TButton;
    Button5: TButton;
    edtGpCode: TEdit;
    Edit1: TEdit;
    Memo3: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
  private
  public
  end;
type StockData = record
    date: integer;
    open: integer;
    high: integer;
    low: integer;
    close: integer;
    amount: integer;
    vol: integer;
    reservation: integer;
  end;
 
var
  FormDataMng: TFormDataMng;
implementation
uses UnitMain;
{$R *.dfm}
function hTot(iHex: string): integer;
begin
  //intToHex(idays, 2)
  hTot := 0;
end;
procedure TFormDataMng.Button1Click(Sender: TObject);
var
  iFileHandle: Integer;
  //idays:word;
  //Buffer: PChar;
  idays: Longword;
  i: integer;
begin
  memo1.Clear;
  try
    iFileHandle := FileOpen(ExtractFilePath(ParamStr(0))+'\data\sh601398.day', fmOpenRead);
    if iFileHandle <= 0 then exit;
    FileSeek(iFileHandle,0,0);
    for i:=0 to 31 do
    begin
      idays := 0;
      FileSeek(iFileHandle,1,1);
      FileRead(iFileHandle,idays,1);
      memo1.Lines.Add(intToStr(i) + ': ' + intToStr(idays));
    end;
    //FileRead(iFileHandle,idays,4);
    //memo1.Lines.Add('日期 ' + intToStr(idays));
    FileClose(iFileHandle);
  except
   
    on E: Exception do
    showmessage(E.Message);
  end;
   
end;
procedure TFormDataMng.Button3Click(Sender: TObject);
var
  i: integer;
  sHexLine, s, sMemo1Line: string;
begin
  memo1.Clear;
  for i := 0 to memo2.Lines.Count - 1 do
  begin
    sHexLine := trim(memo2.Lines.Strings[i]);
    sMemo1Line := '';
    //一行十六进制字符串转换
    while length(sHexLine) > 0 do
    begin
      s := copy(sHexLine,0,1);
      if hTot(s) = 99 then
        sMemo1Line := sMemo1Line + ' '
      else
        sMemo1Line := sMemo1Line + inttostr(hTot(s));
        //sMemo1Line := sMemo1Line + s + ':' + inttostr(hTot(s));
      delete(sHexLine,1,1);
      //memo1.Lines.Add(sHexLine);
    end;
   
    memo1.Lines.Add(sMemo1Line);
  end;
end;
procedure TFormDataMng.Button2Click(Sender: TObject);
var
  iFileHandle: Integer;
  idays: Longword;
begin
  memo1.Clear;
  try
    iFileHandle := FileOpen(ExtractFilePath(ParamStr(0))+'\data\sh601398.day', fmOpenRead);
    if iFileHandle <= 0 then exit;
    FileSeek(iFileHandle,0,0);
    FileRead(iFileHandle,idays,1);
    memo1.Lines.Add(IntToStr(idays) + ' ' + intToHex(idays, 2));
    FileRead(iFileHandle,idays,1);
    memo1.Lines.Add(IntToStr(idays) + ' ' + intToHex(idays, 2));
    FileRead(iFileHandle,idays,1);
    memo1.Lines.Add(IntToStr(idays) + ' ' + intToHex(idays, 2));
    FileRead(iFileHandle,idays,1);
    memo1.Lines.Add(IntToStr(idays) + ' ' + intToHex(idays, 2));           
    {
    for i:=0 to 31 do
    begin
      idays := 0;
      FileSeek(iFileHandle,1,1);
      FileRead(iFileHandle,idays,4);
      memo1.Lines.Add(intToStr(i) + ': ' + IntToStr(Ord(idays)));
    end;
    }
    //FileRead(iFileHandle,idays,4);
    //memo1.Lines.Add('日期 ' + intToStr(idays));
    FileClose(iFileHandle);
  except
   
    on E: Exception do
    showmessage(E.Message);
  end;
end;
procedure TFormDataMng.Button4Click(Sender: TObject);
begin
  //ShowMessage(intToStr(strToInt('$' + '01321b63')));
  //memo1.Lines.Add(intToStr(strToInt64('$' + edit1.Text)));
end;
//显示
procedure TFormDataMng.Button5Click(Sender: TObject);
var
  iFileHandle: Integer;
  iFileLength: Integer;
  idayCount: integer;
  iTmp: Longword;
  date,iDateHex1,iDateHex2,iDateHex3,iDateHex4,
  open,iOpenHex1,iOpenHex2,iOpenHex3,iOpenHex4,
  high,iHighHex1,iHighHex2,iHighHex3,iHighHex4,
  low,iLowHex1,iLowHex2,iLowHex3,iLowHex4,
  close,iCloseHex1,iCloseHex2,iCloseHex3,iCloseHex4,

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。