1

内部にレコードの配列があるレコードの配列の作成に問題があります。

type
    SubjectsRec = array of record
        subjectName : String;
        grade : String;
        effort : Integer;
    end;
    TFileRec = array of record
        examinee : String;
        theirSubjects: array of SubjectsRec;
    end;

var
    tfRec: TFileRec;
    i: Integer;
begin
    setLength(tfRec,10);
    for i:= 0 to 9 do
    begin
       setLength(tfRec[i].theirSubjects,10);
    end;

この後、私はこれを行うことで値を割り当てることを望んでいました:

tfRec[0].theirSubjects[0].subjectName:= "Mathematics";

しかし、私は得る:

エラー: 無効な修飾子です

コンパイルしようとすると。

4

2 に答える 2

2

SubjectsRecレコードの配列として宣言してから、フィールドTheirSubjectsをの配列として宣言しました。SubjectRecsつまりTheirSubjects、レコードの配列の配列です。

次の 2 つの解決策があります。

の代わりにTheirSubjects、型を持つと宣言します。SubjectsRecarray of subjectsRec

TFileRec = array of record
  examinee : string;
  theirSubjects: SubjectsRec;
end;

SubjectsRecまたは配列としてではなく、レコードとして宣言します。これは私のお気に入りです:

SubjectsRec = record
  subjectName : String;
  grade : String;
  effort : Integer;
end;
TFileRec = array of record
  examinee : string;
  theirSubjects: array of SubjectsRec;
end;

また、Pascal の文字列はシングル クォーテーションで区切られているため"Mathematics"'Mathematics'.

于 2012-05-31T13:40:47.437 に答える
1

これを変更する必要があると思います:

tfRec[0].theirSubjects[0].subjectName:= "Mathematics";

tfRec[0].theirSubjects[0].subjectName:= 'Mathematics';
于 2012-07-10T01:55:38.487 に答える