你要用什么格式保存啊?如果你的数据不算复杂的,直接用txt文本保存就行了。
或者可以参考股票软件的数据格式,使用类型文件存储。你要的是那一种?可以试图给个例子。

解决方案 »

  1.   

    还是用数据库算了,如access,用ADO连。
      

  2.   

    to cobi: 有的,能给段代码,启发一下好吗?
      

  3.   

    unit ImportText;interfaceuses
      SysUtils, Classes, ComCtrls, CheckLst;Type
      TImportTextRec = record
        Ext: string[5];
        CanImport: boolean;
      end;  TImportTextObject = class
      private
        FFile: file of TImportTextRec;
        function ExistsType(const Ext: string): boolean;
        procedure GotoFileEnd;
        procedure SetTextCanImport(const Ext: string; Value: boolean);
      protected  public
        constructor Create;
        destructor Destroy; override;
        function AddTextType(const Ext: string; CanImport: boolean): boolean;
        function CanImport(const Ext: string): boolean;
        procedure DeleteTextType(const Ext: string);
        procedure ShowAllType(CheckListBox: TCheckListBox);
        procedure SaveAllType(CheckListBox: TCheckListBox);
      end;implementationuses RainbowApi;{ TImportText }{-------------------- private --------------------}{ 判断一个类型是否存在 }
    function TImportTextObject.ExistsType(const Ext: string): boolean;
    var
      ImportTextRec: TImportTextRec;
    begin
      result := false;
      ReSet(FFile);
      while not eof(FFile) do
      begin
        read(FFile, ImportTextRec);
        if ImportTextRec.Ext = Ext then
        begin
          result := true;
          break;
        end;
      end;
    end;{ 文件指针指向文件尾 }
    procedure TImportTextObject.GotoFileEnd;
    var
      ImportTextRec: TImportTextRec;
    begin
      ReSet(FFile);
      while not eof(FFile) do
        Read(FFile, ImportTextRec);
    end;procedure TImportTextObject.SetTextCanImport(const Ext: string;
      Value: boolean);
    var
      iPos: integer;
      ImportTextRec: TImportTextRec;
    begin
      iPos := 0;
      ReSet(FFile);
      while not eof(FFile) do
      begin
        read(FFile, ImportTextRec);
        if ImportTextRec.Ext = Ext then
        begin
          ImportTextRec.CanImport := Value;
          seek(FFile, iPos);
          write(FFile, ImportTextRec);
          break;
        end;
        inc(iPos);
      end;
    end;
    {-------------------- public --------------------}constructor TImportTextObject.Create;
    begin
      AssignFile(FFile, ProgPath + 'ImportText.dat');
      if FileExists(ProgPath + 'ImportText.dat') then
        ReSet(FFile)
      else begin
        ReWrite(FFile);
        AddTextType('.txt', true);
        AddTextType('.rtf', true);
        AddTextType('.htm', true);
      end;
    end;destructor TImportTextObject.Destroy;
    begin
      CloseFile(FFile);
      inherited;
    end;function TImportTextObject.AddTextType(const Ext: string;
      CanImport: boolean): boolean;
    var
      ImportTextRec: TImportTextRec;
    begin
      if ExistsType(Ext) then
        result := false
      else begin
        GotoFileEnd; //指针到文件尾
        ImportTextRec.Ext := Ext;
        ImportTextRec.CanImport := CanImport;
        write(FFile, ImportTextRec);
      end;
    end;function TImportTextObject.CanImport(const Ext: string): boolean;
    var
      ImportTextRec: TImportTextRec;
    begin
      result := false;
      ReSet(FFile);
      while not eof(FFile) do
      begin
        read(FFile, ImportTextRec);
        if ImportTextRec.Ext = Ext then
        begin
          result := ImportTextRec.CanImport;
          break;
        end;
      end;
    end;procedure TImportTextObject.DeleteTextType(const Ext: string);
    var
      ImportTextRec: TImportTextRec;
      iPos: integer;
    begin
      ReSet(FFile);
      iPos := 0;
      while not eof(FFile) do
      begin
        read(FFile, ImportTextRec);
        if ImportTextRec.Ext = Ext then
        begin
          ImportTextRec.Ext := '';
          Seek(FFile, iPos);
          write(FFile, ImportTextRec);
          break;
        end;
        inc(iPos);
      end;
    end;procedure TImportTextObject.ShowAllType(CheckListBox: TCheckListBox);
    var
      ImportTextRec: TImportTextRec;
    begin
      ReSet(FFile);
      while not eof(FFile) do
      begin
        Read(FFile, ImportTextRec);
        with CheckListBox do
          if ImportTextRec.Ext <> '' then
          begin
            Items.Add(ImportTextRec.Ext);
            Checked[Items.Count - 1] := ImportTextRec.CanImport;
          end;
      end;
    end;procedure TImportTextObject.SaveAllType(CheckListBox: TCheckListBox);
    var
      i: integer;
    begin
      for i := 0 to CheckListBox.Items.Count - 1 do
      begin
        SetTextCanImport(CheckListBox.Items[i], CheckListBox.Checked[i]);
      end;
    end;end.
      

  4.   

    以下的程序就是对胜龙股票分析软件的股票日线数据进行读取的例子:
    unit Umain;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        Memo1: TMemo;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
    type
      slonday = record
      day: cardinal;
      Oprice: cardinal;
      Cprice: cardinal;
      Hprice: cardinal;
      Lprice: cardinal;
      Damout: cardinal;
      Dvolmn: cardinal;
      reserved: Array[0..5] of smallint;
    end;Fslon = file of slonday;var
      Vslon : Fslon;
      Vsday : Slonday;
    implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    begin
      Memo1.Lines.Clear;  AssignFile(vslon,'F:\SLON\DATA\SZ\DAY\0957.day');
      Reset(Vslon);
      while not Eof(Vslon) do
      begin
        Read(Vslon,Vsday);
        Memo1.Lines.Add(inttostr(not Vsday.day)+','+inttostr(not Vsday.Oprice)+','
          +inttostr(not Vsday.Cprice)+','+inttostr(not Vsday.Hprice)+','
          +inttostr(not Vsday.lprice)+','+inttostr(not Vsday.Damout)+','
          +inttostr(not Vsday.Dvolmn));
      end;
      CloseFile(Vslon);
    end;end.
      

  5.   

    to cobi:能留下email吗?
    to taxi:能留下email吗?