Разработка программы психотестирования
Рефераты >> Программирование и компьютеры >> Разработка программы психотестирования

statictext1.Caption:='Всего вопросов '+inttostr(testnum)

end;

end.

Листинг программы RС:

unit Mainfrm;

interface

uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

testtypes, StdCtrls, Spin;

type

TfrmMain = class(TForm)

Memo1: TMemo;

SpinEdit1: TSpinEdit;

Label1: TLabel;

SpinEdit2: TSpinEdit;

Label2: TLabel;

Button1: TButton;

Button2: TButton;

SpinEdit3: TSpinEdit;

Label3: TLabel;

OpenDialog1: TOpenDialog;

SaveDialog1: TSaveDialog;

procedure Button1Click(Sender: TObject);

procedure Button2Click(Sender: TObject);

procedure SpinEdit1Change(Sender: TObject);

procedure SpinEdit2Change(Sender: TObject);

procedure Memo1Change(Sender: TObject);

procedure FormCreate(Sender: TObject);

procedure SpinEdit3Change(Sender: TObject);

private

{ Private declarations }

public

res:array[1 100] of tresult;

varnum:byte;

no:boolean;

end;

var

frmMain: TfrmMain;

implementation

{$R *.DFM}

procedure TfrmMain.Button1Click(Sender: TObject);

var f:file of tresult;

i:byte;

begin

if savedialog1.execute then begin

assignfile(f,savedialog1.filename);

rewrite(f);

for i:=1 to varnum-1 do write(f,res[i]);

closefile(f)

end

end;

procedure TfrmMain.Button2Click(Sender: TObject);

var f:file of tresult;

begin

if opendialog1.execute then begin

assignfile(f,opendialog1.filename);

reset(f);

varnum:=1;

while not eof(f) do begin

read(f,res[varnum]);

inc(varnum)

end;

memo1.text:=res[1].text;

spinedit1.value:=res[1].min;

spinedit2.value:=res[1].max;

spinedit3.value:=1;

closefile(f)

end

end;

procedure TfrmMain.SpinEdit1Change(Sender: TObject);

begin

if no then exit;

res[spinedit3.value].min:=spinedit1.value;

if spinedit2.value<spinedit1.value then spinedit2.value:=spinedit1.value

end;

procedure TfrmMain.SpinEdit2Change(Sender: TObject);

begin

if no then exit;

res[spinedit3.value].max:=spinedit2.value;

end;

procedure TfrmMain.Memo1Change(Sender: TObject);

var i:integer;

begin

if not no then for i:=1 to length(memo1.text) do res[spinedit3.value].text[i]:=memo1.text[i]

end;

procedure TfrmMain.FormCreate(Sender: TObject);

begin

varnum:=1;

no:=false

end;

procedure TfrmMain.SpinEdit3Change(Sender: TObject);

begin

no:=true;

if varnum<spinedit3.value then varnum:=spinedit3.value;

memo1.text:=res[spinedit3.value].text;

spinedit1.value:=res[spinedit3.value].min;

spinedit2.value:=res[spinedit3.value].max;

no:=false;

memo1.SetFocus

end;

end.


Страница: