home *** CD-ROM | disk | FTP | other *** search
- // TBFwSkip.prg
- //
- // TBFwSkip() - skipBlock function implementing general
- // purpose for and while condition
-
- FUNCTION TBFwSkip(nToSkip, bWhile, bFor)
-
- LOCAL nSkipped := 0, ;
- nLastValidRecNum := Recno()
-
- IF nToSkip = 0
- SKIP 0
- RETURN 0
- ENDIF
-
- IF nToSkip > 0
- DO WHILE nSkipped < nToSkip .AND. !eof() .AND. eval(bWhile)
- SKIP
- // Note the last clause here makes a big speed difference
- DO WHILE !eval(bFor) .AND. !eof() .AND. eval(bWhile)
- SKIP
- ENDDO
- IF Eval(bWhile) .AND. !eof()
- // Found a new record matching the scope
- nSkipped++
- nLastValidRecNum := Recno()
- ENDIF
- ENDDO
-
- IF eof() .OR. !eval(bWhile)
- GOTO nLastValidRecNum
- ENDIF
- ELSE
- DO WHILE nSkipped > nToSkip .AND. !bof() .AND. eval(bWhile)
- SKIP -1
- // Note the last clause here makes a big speed difference
- DO WHILE !eval(bFor) .AND. !bof() .AND. eval(bWhile)
- SKIP -1
- ENDDO
- IF Eval(bWhile) .AND. !bof()
- nSkipped--
- nLastValidRecNum := Recno()
- ENDIF
- ENDDO
- IF !eval(bWhile) .OR. bof()
- GOTO nLastValidRecNum
- ENDIF
- ENDIF
-
- RETURN nSkipped