Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Почему не работает проверялка? [D7, XP]


IAMDANIL ©   (2005-11-26 13:43:00) 

Помогите отладить...

procedure TForm2.calculate(Sender: TObject);
var
sinf:startupinfo;
pinf:process_information;
kkk,tickcount:longint;
youranswer:tstringlist;
rightanswer:tstringlist;
filename:string;
feedback:string;
testcount:integer;
timelimit:integer;
istimelimit:boolean;
exitcode:cardinal;
i:integer;
testpath:string;
f:TextFile;
j,k:integer;
begin
if memo1.tag>0 then exit;
j:=0;
memo1.Tag:=1;
memo1.Lines.Add('Ðåçóëüòàòû ïðîâåðêè:');
memo1.Lines.Add('');
{MessageDlg('jkl',mtInformation,mbOKCancel,0);}

 filename:=Form1.Edit1.Text;
 testpath:=Form1.Edit2.Text;
 assignfile(f,testpath+'\testinfo.txt');
 timelimit:=5000;
 testcount:=0;
 if fileexists(testpath+'\testinfo.txt') then
 begin
 reset(f);
 read(f,testcount);
 if not seekeof(f) then read(f,timelimit);
 closefile(f);
 end
 else
 while fileexists(testpath+'\test_'+inttostr(testcount+1)+'.txt') do
 testcount:=testcount+1;
 progress1.MaxValue:=testcount;

 if form1.CheckBox1.Checked then
 ForceDirectories(testpath+'\ÂàøèÎòâåòû');

 for i:=1 to testcount do begin
 renamefile(testpath+'\test_'+inttostr(i)+'.txt',extractfilepath(filename)+'\input.txt');
 fillchar(sinf,sizeof(sinf),0);
 sinf.cb:=sizeof(pinf);
 sinf.wshowwindow:=sw_hide;
 sinf.dwflags:=startf_UsesHowWindow;

 createprocess(pchar('"'+filename+'" < "'+
 extractfilepath(filename)+'input.txt" > "'+
 extractfilepath(filename)+'output.txt"'),nil,nil,nil,false,
 create_new_console or
 normal_priority_class,nil,nil,sinf,pinf);
 tickcount:=gettickcount;
 istimelimit:=true;
 ShowMessage('"'+filename+'" < "'+
 extractfilepath(filename)+'input.txt" > "'+
 extractfilepath(filename)+'output.txt"');
 while ((tickcount+timelimit)>=gettickcount) and istimelimit do

 if waitforsingleobject(pinf.hprocess,0)wait_timeout then istimelimit:=false;

  if istimelimit then begin
  terminateprocess(pinf.hprocess,0);
   feedback:='Time limit exceeded!';
 end
else
begin
 getexitcodeprocess(pinf.hprocess,exitcode);
 kkk:=gettickcount-tickcount;
 if exitcode0 then feedback:='Run-time error!'
 else begin
 youranswer:=tstringlist.create;
 rightanswer:=tstringlist.create;
 if fileexists(extractfilepath(filename)+'\output.txt') then
 youranswer.loadfromfile(extractfilepath(filename)+'\output.txt');
 if fileexists(testpath+'\ans_'+inttostr(i)+'.txt') then
 rightanswer.loadfromfile(testpath+'\ans_'+inttostr(i)+'.txt');
 if youranswer.textrightanswer.text then feedback:='Wrong answer!'
 else feedback:='OK ('+inttostr(kkk)+' ms)';
 youranswer.free;
 rightanswer.free
end;
 end;

 renamefile(extractfilepath(filename)+'\input.txt',testpath+'\test_'+
 inttostr(i)+'.txt');
 memo1.lines.add('  Test '+inttostr(i)+': '+feedback);
 
 if FileExists(ExtractFilePath(filename)+'\output.txt') then
 DeleteFile(ExtractFilePath(filename)+'\output.txt');
 If fileexists(ExtractFilePath(filename)+'\output.txt') and
 Form1.CheckBox1.Checked then RenameFile(ExtractFilePath(filename)
 +'\output.txt',testpath+'\YourAnswers\Ans_'+inttostr(i)+'.txt')
 end;
 memo1.Lines.Add('');
 memo1.lines.add('...completed');
end;
все исходники narod.ru/checker.zip


Anatoly Podgoretsky   (2005-11-27 12:53:00) [1]

IAMDANIL ©   (26.11.05 13:43)  
А зачем ты нам этот мусор вывалил, надо было билет покупать, что бы к тебе приехали сделать отладку


irishka001   (2005-11-27 03:12:00) [2]


> IAMDANIL ©

А что ты хочешь сделать, используя этот код? И в чем собственно проблема?


Джо   (2005-11-26 14:10:00) [3]

А что тут разбираться? В корзину такой код и жизнь сразу станет проще...


Virgo_Style   (2005-11-26 14:09:00) [4]

Интересно, это только я не лююлю разбираться в неформатированном коде непонятного назначения в поисках неизвестной проблемы, или это общая беда? %-)


Наверх

Титульная страница Поиск, карта сайта Написать письмо