|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, StdCtrls, ExtCtrls, XPMan; | |
Tmainform = class(TForm) | |
Panel1: TPanel; | |
GroupBox1: TGroupBox; | |
questmemo: TMemo; | |
answ1: TRadioButton; | |
answ2: TRadioButton; | |
answ3: TRadioButton; | |
answ4: TRadioButton; | |
Button1: TButton; | |
Button3: TButton; | |
Panel2: TPanel; | |
Button4: TButton; | |
GroupBox2: TGroupBox; | |
sourcepathedit: TEdit; | |
Button5: TButton; | |
OpenDialog: TOpenDialog; | |
procedure FormCreate(Sender: TObject); | |
procedure Button5Click(Sender: TObject); | |
procedure Button3Click(Sender: TObject); | |
procedure Button1Click(Sender: TObject); | |
procedure Button4Click(Sender: TObject); | |
TQuestion = record | |
QuestionText, Answer1, Answer2, Answer3, Answer4: string; | |
RightAnswer: integer; | |
ok: boolean; | |
mainform: Tmainform; | |
count, cur: integer; | |
questions: array[1..1000] of TQuestion; | |
validquestions: boolean; | |
procedure refreshquest(count: integer); | |
questmemo.Text := questions[count].QuestionText; | |
answ1.Caption := questions[count].Answer1; | |
answ2.Caption := questions[count].Answer2; | |
answ3.Caption := questions[count].Answer3; | |
answ4.Caption := questions[count].Answer4; | |
questions[i].QuestionText := ''; | |
questions[i].Answer1 := ''; | |
questions[i].Answer2 := ''; | |
questions[i].Answer3 := ''; | |
questions[i].Answer4 := ''; | |
questions[i].RightAnswer := 0; | |
function akapos(s: string; symb: char; part: integer): integer; | |
i, cnt: integer; | |
for i := 1 to length(s) do | |
if cnt = part then | |
result := i; | |
procedure Tmainform.FormCreate(Sender: TObject); | |
quest: TextFile; | |
assignfile (quest, 'questions.txt'); | |
messagedlg('questions.txt is not found in the program local directory!'+#13 | |
+'Please select correct file path!', mtWarning, [mbOk], 0); | |
validquestions := true; | |
while not EOF (quest) do | |
readln (quest, s); | |
questions[count].QuestionText := copy (s, 1, akapos(s,'|',1)-1); | |
questions[count].Answer1 := copy (s, akapos(s,'|',1)+1, | |
akapos(s,'|',2)-akapos(s,'|',1)-1); | |
questions[count].Answer2 := copy (s, akapos(s,'|',2)+1, akapos(s,'|',3)- | |
akapos(s,'|',2)-1); | |
questions[count].Answer3 := copy (s, akapos(s,'|',3)+1, akapos(s,'|',4)- | |
&am | |