home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 25.2. General-purpose database b:skipBlock function.
- Author: Craig Yellick
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
- function SkipRec(howMany)
- /*
- General-purpose record skipping function for use with
- TBrowse skipBlocks. TBrowse will indicate how many records
- it wants to skip, and in what direction. Positive number
- indicates skip forward, negative indicates backwards.
-
- This function must return the number of records it was able to
- skip.
- */
- local actual := 0
-
- // Negative = Move backward.
- do case
- case howMany < 0
-
- // Keep skipping backward until we skip the number
- // requested, or run out of records to skip.
- do while (actual > howMany) .and. (.not. bof())
- skip -1
- // Can't count the skip if we hit beginning-of-file.
- if .not. bof()
- actual--
- endif
- enddo
-
- // Positive = Move forward.
- case howMany > 0
-
- // Keep skipping forward until we skip the number
- // requested, or run out of records to skip.
- do while (actual < howMany) .and. (.not. eof())
- skip +1
- // Can't count the skip if we hit end-of-file.
- if .not. eof()
- actual++
- endif
- enddo
-
- // Don't leave database parked on the
- // phantom end-of-file record.
- if eof()
- skip -1
- endif
-
- // No movement requested, re-read current record.
- otherwise
- skip 0
- endcase
-
- return actual
-
- // end of file CHP2502.PRG
-