Почему выдает ошибку - "Project Project1.exe raised exception class EStringListError
нажимаю "ок" при выводе ошибки
после чего показывает это "кар "12" "
Так же не удается отобразить файле в моем проекте
файл содержимым.
вот сам код формы, где и должен выводиться тест/ содержимое файла:
Код:
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, ExtCtrls, StdCtrls, ComCtrls;
type
TForm7 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
TabControl1: TTabControl;
RichEdit1: TRichEdit;
RadioGroup1: TRadioGroup;
Bevel1: TBevel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure TabControl1Change(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
// procedure RichEdit1Change(Sender: TObject);
// procedure Panel1Click(Sender: TObject);
// procedure BitBtn1Click(Sender: TObject);
// procedure RadioGroup1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
{Spis_tem1.txt}
test:tstrings; {Tema1.txt, Tema2.txt, Tema3.txt }
nom, kol, { Tema1.txt, Tema2.txt, Tema3.txt }
sum, pos:integer;
pr:boolean;
procedure zap_rez;
function patch:string;
end;
rez=record
user:string[30];
rez_sum:integer;
data:string[8];
time:string[8];
end;
var
Form7: TForm7;
f_rez:file of rez;
zap:rez;
implementation
uses Unit1, Unit2; //Unit11;
{$R *.dfm}
procedure tform7.zap_rez;
begin
assignfile(f_rez, 'rez.dat');
{$I-}
reset(f_rez);
{$I+}
if ioresult<>0 then
begin
showmessage('file not');
rewrite(f_rez);
end;
seek(f_rez,filesize(f_rez));
with zap do
begin
user:=Form7.name;
rez_sum:=Form7.sum;
data:= datetostr(now);
time:= timetostr(now);
end;
write(f_rez,zap);
closefile(f_rez);
end;
function tform7.patch: string;
begin
patch := extractfilepath(paramstr(0));
end;
procedure TForm7.FormCreate(Sender: TObject);
var
i:integer;
begin
sum := 0;
nom := 1;
test := tstringlist.Create;
if fileexists(patch + 'Tema1.txt') then
test.loadfromfile(patch + 'Tema1.txt');
kol := strtoint(test.strings[0]);
Form7.TabControl1.tabs.Clear;
for i:=0 to kol-1 do
begin
form7.TabControl1.tabs.append('Âîïðîñ ' +inttostr(i+1));
end;
for i:=nom to nom + 4 do
Form7.Richedit1.Lines.append(test.strings[i]);
Form7.Radiogroup1.items.Clear;
for i:=nom + 6 to nom + 8 do
form7.RadioGroup1.items.append(test.strings[i]);
end;
procedure TForm7.SpeedButton1Click(Sender: TObject);
begin
if RadioGroup1.itemindex <> -1 then
begin
if (RadioGroup1.itemindex + 1 = strtoint(Form7.test.strings[Form7.nom + 5]))
then
begin
Form7.sum := Form7.sum + 1;
Application.MessageBox('Îòâåò âåðíûé', 'Âàø ðåçóëüòàò',
mb_iconAsterisk + mb_ok);
end
else
Application.MessageBox('îòâåò íå âåðíûé', 'Âàø ðåçóëüòàò',
mb_iconAsterisk + mb_ok);
TabControl1Change(nil);
end
else
Application.MessageBox('vi ne vibrali otvet', 'Vash resultat',
mb_iconAsterisk + mb_ok);
end;
procedure TForm7.SpeedButton3Click(Sender: TObject);
begin
Form7.Close;
end;
procedure TForm7.TabControl1Change(Sender: TObject);
var
i, j: integer;
begin
if TabControl1.tabs.Count - 1 > -1 then
TabControl1.tabs.Delete(0);
RadioGroup1.items.Clear;
RichEdit1.Lines.Clear;
if Form7.nom < Form7.test.Count - 9 then
begin
Form7.nom := Form7.nom + 9;
RichEdit1.Lines.Clear;
for i := Form7.nom to Form7.nom + 4 do
RichEdit1.Lines.append(Form7.test.strings[i]);
RadioGroup1.items.Clear;
for i := Form7.nom + 6 to Form7.nom + 8 do
RadioGroup1.items.append(Form7.test.strings[i]);
end
else
begin
if messagedlg('testov bolshe net', mtinformation, [mbok], 0) = mrok then
begin
RadioGroup1.items.Clear;
RichEdit1.Lines.Clear;
end;
end;
end;
procedure TForm7.SpeedButton2Click(Sender: TObject);
begin
Form7.TabControl1.tabs.Clear;
Form7.RichEdit1.Lines.Clear;
Form7.RadioGroup1.items.Clear;
// form7.Label1.Caption:='';
Form7.name := inputbox('Ââîä èìåíè ïîëüçîâàòåëÿ', 'Ââåäèòå èìÿ', '');
Form7.zap_rez;
end;
end.