就是一个record变量,赋过值后怎么重新初始化,每个数据项全部为零或nil。

解决方案 »

  1.   

    就是一个record变量赋过值后,重新初始化,数据项全部为0或nil。
      

  2.   

    动态数据在记录中是指针地址,和记录不一定是连续的内存空间,所以不能用fillchar一次性清空.
      

  3.   

    //自己测试测试就知道了
    procedure TForm1.Button1Click(Sender: TObject);
    type
      TRecord = record
        I: Integer;
        A: array of Char;
      end;
    var
      R: TRecord;
    begin
      R.I := 10;
      SetLength(R.A, R.I);
      ShowMessage(IntToStr(Length(R.A)));
      FillChar(R, SizeOf(R), 0);
      ShowMessage(IntToStr(Length(R.A)));
    end;
      

  4.   

    //自己测试测试就知道了
    procedure TForm1.Button1Click(Sender: TObject);
    type
      TRecord = record
        I: Integer;
        A: array of Char;
      end;
    var
      R: TRecord;
    begin
      R.I := 10;
      SetLength(R.A, R.I);
      ShowMessage(IntToStr(Length(R.A)));
      FillChar(R, SizeOf(R), 0);
      ShowMessage(IntToStr(Length(R.A)));
    end;
      

  5.   

    //自己测试测试就知道了
    procedure TForm1.Button1Click(Sender: TObject);
    type
      TRecord = record
        I: Integer;
        A: array of Char;
      end;
    var
      R: TRecord;
    begin
      R.I := 10;
      SetLength(R.A, R.I);
      ShowMessage(IntToStr(Length(R.A)));
      FillChar(R, SizeOf(R), 0);
      ShowMessage(IntToStr(Length(R.A)));
    end;
      

  6.   

    for i:=0 to record.count-1 do
      record[i].Free;