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

Вниз

Ошибка при работе со строковыми переменными?   Найти похожие ветки 

 
Lexa   (2005-08-01 06:57) [0]

Судари, может кто на свежую голову разглядит ошибку в процедуре?
У меня просто уже в глазах рябит... Никаких Exception"ов не возникает - не работает и все. Ерунда какая-нибудь - точно.
"Зоны риска" выделю Bold"ом, точнее одну - они аналогичны.  Заранее благодарю всех, кто решит напрячься.

procedure unification(F1,F2,S1,S2: string; DC1: TDIPcre; L: TLabel);
var
str1, str2: string;
lg1,lg2: integer;
fc: string;
y1,y2: integer;
begin
DC1.MatchPattern := "\S";
DC1.SetSubjectStr(F1);
DC1.Match(1);
if DC1.SubStrCount < 1 then
  begin
  DC1.MatchPattern := "\S";
  DC1.SetSubjectStr(F2);
  DC1.Match(1);
  if DC1.SubStrCount < 1 then
     begin
     L.Caption := fc;
     end
  else
     begin
     L.Caption := "no1";
     end;
  end
else
  begin
  str1 := DC1.MatchedStr;
  lg1 := DC1.MatchedStrLength;
  DC1.MatchPattern := "\S";
  DC1.SetSubjectStr(F2);
  DC1.Match(1);
  if DC1.SubStrCount < 1 then
     begin
     L.Caption := "no2";
     end
  else
     begin
     str2 := DC1.MatchedStr;
     lg2 := DC1.MatchedStrLength;
     if str1 = str2 then
        begin
        fc := fc + str1;
        delete(F1, 2, lg1);
        delete(F2, 2, lg2);
        unification(F1, F2, S1, S2, L);
        end
     else                               //Символы не совпадают
        begin                           //1 символ 1 формулы - временная переменная?
        DC1.MatchPattern := "t\d+";
        DC1.SetSubjectStr(F1);
        DC1.Match(1);
        if DC1.SubStrCount > 0 then
           begin                        //1 символ 2 формулы - временная переменная?
           str1 := " "+DC1.MatchedStr;
           lg1 := DC1.MatchedStrLength;
           DC1.MatchPattern := "t\d+";
           DC1.SetSubjectStr(F2);
           DC1.Match(1);
           if DC1.SubStrCount > 0 then
              begin                     //Ищем временную переменную с меньшим индексом
              str2 := " "+DC1.MatchedStr;
              lg2 := DC1.MatchedStrLength;
              DC1.MatchPattern := "\d+";
              DC1.SetSubjectStr(str1);
              DC1.Match(1);
              y1 := StrToInt(DC1.MatchedStr);
              DC1.MatchPattern := "\d+";
              DC1.SetSubjectStr(str2);
              DC1.Match(1);
              y2 := StrToInt(DC1.MatchedStr);
              if y1 > y2 then
                 begin
                 fc := fc + str2;
                 delete(F1, 2, lg1);
                 delete(F2, 2, lg2);
                 unification(F1, F2, S1, S2, L);
                 end
              else
                 begin
                 fc := fc + str2;
                 delete(F1, 2, lg1);
                 delete(F2, 2, lg2);
                 unification(F1, F2, S1, S2, L);
                 end;
              end
           else
              begin                     //1 символ 2 формулы - функтор?
              DC1.MatchPattern := "f\d+\((?>[^()]+)\)";
              DC1.SetSubjectStr(F2);
              DC1.Match(1);
              if DC1.SubStrCount > 0 then
                 begin
                 str2 := DC1.MatchedStr;
                 lg2 := DC1.MatchedStrLength;
                 fc := fc + str2;
                 delete(F1, 2, lg1);
                 delete(F2, 2, lg2);
                 unification(F1, F2, S1, S2, L);
                 end
              else
                 begin                  //1 символ 2 формулы - индивидная переменная?
                 DC1.MatchPattern := "y\d+|x\d+";
                 DC1.SetSubjectStr(F2);
                 DC1.Match(1);
                 if DC1.SubStrCount > 0 then
                    begin               //Индивидная переменная переменная связана квантором?
                 str2 := DC1.MatchedStr;
                    lg2 := DC1.MatchedStrLength;
                    DC1.MatchPattern := "(?<=E|A)"+str2;
                    DC1.SetSubjectStr(S2);
                    DC1.Match(1);
                    if DC1.SubStrCount > 0 then
                       begin
                       L.Caption := "no3";
                       end
                    else
                       begin
                       fc := fc + str2;
                       delete(F1, 2, lg1);
                       delete(F2, 2, lg2);
                       unification(F1, F2, S1, S2, L);
                       end;
                   
                    end
                 else
                    begin
                    L.Caption := "no4";
                    end;
                 end;
              end;
           end
        else
           begin                        //1 символ 2 формулы - временная переменная?
           DC1.MatchPattern := "t\d+";
           DC1.SetSubjectStr(F2);
           DC1.Match(1);
           if DC1.SubStrCount > 0 then
              begin                     //1 символ 1 формулы - функтор?
              str2 := DC1.MatchedStr;
              lg2 := DC1.MatchedStrLength;
              DC1.MatchPattern := "f\d+\((?>[^()]+)\)";
              DC1.SetSubjectStr(F1);
              DC1.Match(1);
              if DC1.SubStrCount > 0 then
                 begin
                 str1 := DC1.MatchedStr;
                 lg1 := DC1.MatchedStrLength;
                 fc := fc + str1;
                 delete(F1, 2, lg1);
                 delete(F2, 2, lg2);
                 unification(F1, F2, S1, S2, L);
                 end
              else
                 begin                  //1 символ 1 формулы - индивидная переменная?
                 DC1.MatchPattern := "y\d+ | x\d+";
                 DC1.SetSubjectStr(F1);
                 DC1.Match(1);
                 if DC1.SubStrCount > 0 then
                    begin               //Индивидная переменная переменная связана квантором?
                    str1 := DC1.MatchedStr;
                    lg1 := DC1.MatchedStrLength;
                    DC1.MatchPattern := "(?<=E|A)"+str1;
                    DC1.SetSubjectStr(S1);
                    DC1.Match(1);
                    if DC1.SubStrCount > 0 then
                       begin
                       L.Caption := "no5";
                       end
                    else
                       begin
                       fc := fc + str1;
                       delete(F1, 2, lg1);
                       delete(F2, 2, lg2);
                       unification(F1, F2, S1, S2, L);
                       end;
                    end
                 else
                    begin
                    L.Caption := "no6";
                    end;
                 end;
              end
           else
              begin
              L.Caption := "no7";
              end;
           end;
        end;
  end;
end;
end;


 
Lexa   (2005-08-01 07:08) [1]

Да, забыл уточнить: процедура сравнивает 2 формулы на предмет их подобия. Например формулы
Ex1Ay1(t1,x2) и
Ex1Ay1(y3,x2) побобны.

Временная переменная t1 конкретизируется индивидной - y3


 
Digitman ©   (2005-08-01 13:08) [2]

что говорит встр.отладчик ?


 
Amido   (2005-08-01 17:16) [3]

Ого какая... еще и с рекурсией... Отладчик, отладчик + один сплошной брейкпойнт =]



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

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

Наверх




Память: 0.49 MB
Время: 0.042 c
6-1115755390
whiletruedo
2005-05-11 00:03
2005.08.21
как обратиться к открытому IE?


1-1122973306
Bless
2005-08-02 13:01
2005.08.21
Удаление страницы из Excel


14-1122466072
desam
2005-07-27 16:07
2005.08.21
jimm


14-1122567143
Ego
2005-07-28 20:12
2005.08.21
Творческий кризис.


1-1123081438
webpauk
2005-08-03 19:03
2005.08.21
Закрытие приложения