: Hello, : : Firstly, I would like to say i'm kinda new to programming, so this : maybe just a simple error. But the fact is, its been troubling me : for days now, and I can't seem to find out how to fix it : : Anyway, : I am unable to run my program, The area I have highlighted in red is : the problem, and I get the message "Object or Class type Required) : : [code]: unit Unit2; : : interface : : uses : Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, : Dialogs, StdCtrls, Mask; : : const examinername = 'Examiner.Dat'; : centrename = 'Centre.Dat'; : AdminPay = '95'; : TaxRate = '0.78'; : Subject1 = '4.52'; : Subject2 = '3.75'; : Subject3 = '7.88'; : : Type : examinertype = record : ExamName:string[50]; : ExamNum:string[6]; : ExamAdd:String[50]; : SubRefCode:string[5]; : Taxflag:boolean; : end; : : : centretype = record : CentNum: string[5]; : SubRefcode: string[5]; : ExamNum: string[6]; : NumOfCand: integer; : : end; : : type : TForm2 = class(TForm) : Label1: TLabel; : MaskEdit1: TMaskEdit; : MaskEdit2: TMaskEdit; : MaskEdit3: TMaskEdit; : MaskEdit4: TMaskEdit; : Label2: TLabel; : Label3: TLabel; : Label4: TLabel; : Label5: TLabel; : CheckBox1: TCheckBox; : Label6: TLabel; : Button1: TButton; : procedure Button1Click(Sender: TObject); : { procedure Button2Click(Sender: TObject); } : private : { Private declarations } : public : { Public declarations } : end; : : var : Form2: TForm2; : examinerFile : file of examinertype ; : : : implementation : : {$R *.dfm} : : : procedure TForm2.Button1Click(Sender: TObject); : begin : assignfile(examinerfile, examinername); : : Reset(examinerfile); : : seek(examinerfile, filesize(examinerfile)); : : examinertype.examname := maskedit1.text; : [color=red] : examinertype.examnum := maskEdit2.text;[/color] : : examinertype.examadd := maskedit3.text; : : examinertype.subrefcode := maskedit4.text; : : If checkbox1.checked = true then : : examinerrec.taxflag := true; : : If checkbox1.checked = false then : : examinerrec.taxflag := false;} : : : : {write(examinerfile,examinertype); : : Closefile(examinerfile); : : maskEdit1.text := ''; : : maskedit2.text := ''; : : maskedit3.text := ''; : : maskedit4.text := ''; : : : : showmessage('Record has been added!'); : : checkbox1.checked := false; : end; : : : : end.[/code]: : : : I would really appreciate your help on this. : : Thanks : ExaminerType is a type not a variable. Types cannot hold values, but only define memory structure. Solution: you need to define a variable of that type and fill that using the the various assignments.
Comments
:
: Firstly, I would like to say i'm kinda new to programming, so this
: maybe just a simple error. But the fact is, its been troubling me
: for days now, and I can't seem to find out how to fix it
:
: Anyway,
: I am unable to run my program, The area I have highlighted in red is
: the problem, and I get the message "Object or Class type Required)
:
: [code]: unit Unit2;
:
: interface
:
: uses
: Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
: Dialogs, StdCtrls, Mask;
:
: const examinername = 'Examiner.Dat';
: centrename = 'Centre.Dat';
: AdminPay = '95';
: TaxRate = '0.78';
: Subject1 = '4.52';
: Subject2 = '3.75';
: Subject3 = '7.88';
:
: Type
: examinertype = record
: ExamName:string[50];
: ExamNum:string[6];
: ExamAdd:String[50];
: SubRefCode:string[5];
: Taxflag:boolean;
: end;
:
:
: centretype = record
: CentNum: string[5];
: SubRefcode: string[5];
: ExamNum: string[6];
: NumOfCand: integer;
:
: end;
:
: type
: TForm2 = class(TForm)
: Label1: TLabel;
: MaskEdit1: TMaskEdit;
: MaskEdit2: TMaskEdit;
: MaskEdit3: TMaskEdit;
: MaskEdit4: TMaskEdit;
: Label2: TLabel;
: Label3: TLabel;
: Label4: TLabel;
: Label5: TLabel;
: CheckBox1: TCheckBox;
: Label6: TLabel;
: Button1: TButton;
: procedure Button1Click(Sender: TObject);
: { procedure Button2Click(Sender: TObject); }
: private
: { Private declarations }
: public
: { Public declarations }
: end;
:
: var
: Form2: TForm2;
: examinerFile : file of examinertype ;
:
:
: implementation
:
: {$R *.dfm}
:
:
: procedure TForm2.Button1Click(Sender: TObject);
: begin
: assignfile(examinerfile, examinername);
:
: Reset(examinerfile);
:
: seek(examinerfile, filesize(examinerfile));
:
: examinertype.examname := maskedit1.text;
: [color=red]
: examinertype.examnum := maskEdit2.text;[/color]
:
: examinertype.examadd := maskedit3.text;
:
: examinertype.subrefcode := maskedit4.text;
:
: If checkbox1.checked = true then
:
: examinerrec.taxflag := true;
:
: If checkbox1.checked = false then
:
: examinerrec.taxflag := false;}
:
:
:
: {write(examinerfile,examinertype);
:
: Closefile(examinerfile);
:
: maskEdit1.text := '';
:
: maskedit2.text := '';
:
: maskedit3.text := '';
:
: maskedit4.text := '';
:
:
:
: showmessage('Record has been added!');
:
: checkbox1.checked := false;
: end;
:
:
:
: end.[/code]:
:
:
: I would really appreciate your help on this.
:
: Thanks
:
ExaminerType is a type not a variable. Types cannot hold values, but only define memory structure.
Solution: you need to define a variable of that type and fill that using the the various assignments.