information:string;就行了
Delphi中的string类型很强大,我们知道普通的字符串长度最大为256个字符,但Delphi中string类型在默认情况下长度可以达到2G。

解决方案 »

  1.   

    如果你使用了String类型,那么就不能使用Packed关键字。你也可以使用微软提供的ISTREAM和ISTROAGE接口进行结构化的数据存取!!!
      

  2.   

    ansistring 是没有长度限制的字符串类型,string默认为ansistring类型,
    所以直接定义为string 就行了!
      

  3.   

    type 
      TRecord=packed recod
        name:string[20];
        information:array[0..1023] of char;
      end;
      

  4.   

    定义为string没有错,在D6中我也经常这样做。不过我不知道在D5中可不可以。
    事实上从你的需求来看,根本就不需要定长的记录。
      

  5.   


    强烈建议用字符数组.array[0..511] of char ////pchar
      

  6.   

    type
     tt=packed record
      t:string;
      end;ai!!!!!我怎么运行通过了???????????????????
      

  7.   

    通各位高手的提示,问题已经解决,但是又发现一个问题,有可能出现乱码,
    源码如下:unit SaveDB;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;
    type
      TRecord=packed record
        name:string[20];
        information:array[0..1023] of char;
      end;
      RF= file of TRecord;
    type
      TForm1 = class(TForm)
        Memo1: TMemo;
        Button1: TButton;
        Memo2: TMemo;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      records:TRecord;
      RFS:RF;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    var
      i:integer;
    begin
      AssignFile(RFS, 'c:\a.txt');
      if FileExists('c:\a.txt') then
        Reset(RFS)
      else
        Rewrite(RFS);
      records.name :='asdfasdf';
      for i:=0 to 1023 do
      records.information[i] :=Pchar(copy(Memo1.Text,i,1))^;  Write(RFS, records);
      seek(rfs,0);
      read(rfs,records);
      Memo2.Text:=records.information;end;end.