Index: bits.inc
===================================================================
--- bits.inc	(wersja 14086)
+++ bits.inc	(kopia robocza)
@@ -282,6 +282,45 @@
 { and when it is set to False it looks for bits that are turned      }
 { off (0).                                                           }
 
+function TBits.FindNextRaw(start : longint;state : boolean) : longint;
+var
+   loop : longint;
+   loop2 : longint;
+   startIndex : longint;
+   stopIndex : longint;
+   compareVal : cardinal;
+begin
+   result := -1; {should only occur if none are set}
+   if state = False then
+      compareVal := $FFFFFFFF  { looking for off bits }
+   else
+      compareVal := $00000000; { looking for on bits }
+   inc(start);
+   loop := (start) div 32;
+   if loop>=fSize then exit;
+   repeat
+      if FBits^[loop] <> compareVal then begin
+
+         startIndex := loop shl BITSHIFT;
+         stopIndex:= startIndex +MASK+1;
+         if start > startIndex then startIndex:=start;
+         if stopIndex>(FBSize ) then stopIndex:=fbSize;
+         writeln(startIndex,' ',stopIndex);
+         for loop2 := startIndex to stopIndex -1 do
+         begin
+            if get(loop2) = state then
+            begin
+               exit(loop2);
+            end;
+         end;
+      end;
+      inc(loop);
+   until (loop>=FSize);
+
+end;
+
+
+
 function TBits.FindFirstBit(state : boolean) : longint;
 var
    loop : longint;
@@ -323,16 +362,14 @@
 function TBits.FindNextBit : longint;
 var
    loop : longint;
-   maxVal : longint;
 begin
    result := -1;  { will occur only if no other bits set to }
                   { current findState                        }
 
    if findIndex > -1 then { must have called FindFirstBit first }
    begin                  { or set the start index              }
-      maxVal := (FSize * 32) - 1;
 
-      for loop := findIndex + 1 to maxVal  do
+      for loop := findIndex + 1 to FBSize-1  do
       begin
          if get(loop) = findState then
          begin
