Ignore:
Timestamp:
Feb 8, 2007, 9:15:07 PM (19 years ago)
Author:
RBRi
Message:

improved TopicByTitleSearch #6 fixed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NewView/HelpFile.pas

    r43 r74  
    700700var
    701701  i: longint;
    702   Topic: TTopic;
     702  tmpTopic: TTopic;
     703  tmpLevel : integer;
     704  tmpMore : boolean;
    703705begin
    704706  result := nil;
    705   for i := 0 to _Topics.Count - 1 do
    706   begin
    707     Topic := _Topics[ i ];
    708     if StrStarts( SearchText, Topic.TitlePtr ^ ) then
     707
     708  tmpLevel := 0;
     709  repeat
     710    tmpMore := false;
     711    inc(tmpLevel);
     712    for i := 0 to _Topics.Count - 1 do
    709713    begin
    710       result := Topic;
    711       exit;
    712     end;
    713   end;
     714      tmpTopic := _Topics[i];
     715      if tmpLevel = tmpTopic.ContentsLevel then
     716      begin
     717        if StrStarts( SearchText, tmpTopic.TitlePtr ^ ) then
     718        begin
     719          result := tmpTopic;
     720          exit;
     721        end;
     722      end;
     723      if tmpLevel < tmpTopic.ContentsLevel then
     724      begin
     725        tmpMore := True;
     726      end;
     727    end;
     728  until NOT tmpMore;
    714729end;
    715730
     
    717732var
    718733  i: longint;
    719   Topic: TTopic;
     734  tmpTopic: TTopic;
     735  tmpLevel : integer;
     736  tmpMore : boolean;
    720737begin
    721738  result := nil;
    722   for i := 0 to _Topics.Count - 1 do
    723   begin
    724     Topic := _Topics[ i ];
    725     if CaseInsensitivePos( SearchText, Topic.TitlePtr ^ ) > 0 then
     739
     740  tmpLevel := 0;
     741  repeat
     742    tmpMore := false;
     743    inc(tmpLevel);
     744    for i := 0 to _Topics.Count - 1 do
    726745    begin
    727       result := Topic;
    728       exit;
    729     end;
    730   end;
     746      tmpTopic := _Topics[i];
     747      if tmpLevel = tmpTopic.ContentsLevel then
     748      begin
     749        if CaseInsensitivePos( SearchText, tmpTopic.TitlePtr ^ ) > 0 then
     750        begin
     751          result := tmpTopic;
     752          exit;
     753        end;
     754      end;
     755      if tmpLevel < tmpTopic.ContentsLevel then
     756      begin
     757        tmpMore := True;
     758      end;
     759    end;
     760  until NOT tmpMore;
    731761end;
    732762
Note: See TracChangeset for help on using the changeset viewer.