Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.12.11;
Скачать: CL | DM;

Вниз

Почему не работает проверялка?   Найти похожие ветки 

 
IAMDANIL ©   (2005-11-26 13:43) [0]

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

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 exitcode<>0 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.text<>rightanswer.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


 
Virgo_Style ©   (2005-11-26 14:09) [1]

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


 
Джо ©   (2005-11-26 14:10) [2]

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


 
irishka001 ©   (2005-11-27 03:12) [3]


> IAMDANIL ©

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


 
Anatoly Podgoretsky ©   (2005-11-27 12:53) [4]

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



Страницы: 1 вся ветка

Текущий архив: 2005.12.11;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.047 c
14-1132652928
DelphiN!
2005-11-22 12:48
2005.12.11
Бесплатный домен+хостинг с поддержкой ASP.NET или PHP


3-1130411409
diwww
2005-10-27 15:10
2005.12.11
Получить позицию первой выводимой записи в DBGrid-е


8-1120937755
Yura32
2005-07-09 23:35
2005.12.11
OpenDialog


11-1113242736
alex_s
2005-04-11 22:05
2005.12.11
добавление юнитов в форму


4-1128594625
NikNet
2005-10-06 14:30
2005.12.11
Как добавить скин для ТоолБар?, Помогите кодом