home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP25.EXE / CHP2502.PRG < prev    next >
Encoding:
Text File  |  1991-06-12  |  1.6 KB  |  64 lines

  1. /*
  2.    Listing 25.2. General-purpose database b:skipBlock function.
  3.    Author: Craig Yellick
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11. function SkipRec(howMany)
  12. /*
  13.    General-purpose record skipping function for use with
  14.    TBrowse skipBlocks. TBrowse will indicate how many records
  15.    it wants to skip, and in what direction. Positive number
  16.    indicates skip forward, negative indicates backwards.
  17.  
  18.    This function must return the number of records it was able to
  19.    skip.
  20. */
  21. local actual := 0
  22.  
  23.   //  Negative = Move backward.
  24.   do case
  25.   case howMany < 0
  26.  
  27.     //  Keep skipping backward until we skip the number
  28.     //  requested, or run out of records to skip.
  29.     do while (actual > howMany) .and. (.not. bof())
  30.       skip -1
  31.       //  Can't count the skip if we hit beginning-of-file.
  32.       if .not. bof()
  33.         actual--
  34.       endif
  35.     enddo
  36.  
  37.   //  Positive = Move forward.
  38.   case howMany > 0
  39.  
  40.     //  Keep skipping forward until we skip the number
  41.     //  requested, or run out of records to skip.
  42.     do while (actual < howMany) .and. (.not. eof())
  43.       skip +1
  44.       //  Can't count the skip if we hit end-of-file.
  45.       if .not. eof()
  46.         actual++
  47.       endif
  48.     enddo
  49.  
  50.     //  Don't leave database parked on the
  51.     //  phantom end-of-file record.
  52.     if eof()
  53.       skip -1
  54.     endif
  55.  
  56.   //  No movement requested, re-read current record.
  57.   otherwise
  58.     skip 0
  59.   endcase
  60.  
  61. return actual
  62.  
  63. // end of file CHP2502.PRG
  64.