home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a065 / 1.img / TBLIB.EXE / TBFWSKIP.PRG < prev    next >
Encoding:
Text File  |  1992-03-09  |  1.4 KB  |  51 lines

  1.     // TBFwSkip.prg
  2.     //
  3.     // TBFwSkip()       - skipBlock function implementing general
  4.     //                    purpose for and while condition
  5.  
  6.     FUNCTION TBFwSkip(nToSkip, bWhile, bFor)
  7.     
  8.     LOCAL nSkipped := 0, ;
  9.           nLastValidRecNum := Recno()
  10.  
  11.       IF nToSkip = 0
  12.         SKIP 0
  13.         RETURN 0
  14.       ENDIF
  15.  
  16.       IF nToSkip > 0
  17.         DO WHILE nSkipped < nToSkip .AND. !eof() .AND. eval(bWhile)
  18.           SKIP
  19.           // Note the last clause here makes a big speed difference
  20.           DO WHILE !eval(bFor) .AND. !eof() .AND. eval(bWhile)
  21.             SKIP
  22.           ENDDO
  23.           IF Eval(bWhile) .AND. !eof()
  24.             // Found a new record matching the scope
  25.             nSkipped++
  26.             nLastValidRecNum := Recno()
  27.           ENDIF
  28.         ENDDO
  29.     
  30.         IF eof() .OR. !eval(bWhile)
  31.           GOTO nLastValidRecNum
  32.         ENDIF
  33.       ELSE
  34.         DO WHILE nSkipped > nToSkip .AND. !bof() .AND. eval(bWhile)
  35.           SKIP -1
  36.           // Note the last clause here makes a big speed difference
  37.           DO WHILE !eval(bFor) .AND. !bof() .AND. eval(bWhile)
  38.             SKIP -1
  39.           ENDDO
  40.           IF Eval(bWhile) .AND. !bof()
  41.             nSkipped--
  42.             nLastValidRecNum := Recno()
  43.           ENDIF
  44.         ENDDO
  45.         IF !eval(bWhile) .OR. bof()
  46.           GOTO nLastValidRecNum
  47.         ENDIF
  48.       ENDIF
  49.  
  50.     RETURN nSkipped
  51.