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

  1. /*
  2.    Listing 25.11. ArraySkip(), a b:skipBlock function for arrays.
  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. //───── NOTE: must compile with the /N option!
  12.  
  13. function ArraySkip(aLen, curPos, howMany)
  14. /*
  15.    General purpose array skipping function intended for
  16.    use with TBrowse b:skipBlocks. You must pass the curPos
  17.    parameter by reference (use the @ operator) for this
  18.    function to work correctly with TBrowse.
  19. */
  20.  
  21. local actual
  22.  
  23. if howMany >= 0                // Moving forward?
  24.   if (curPos +howMany) > aLen     // Can't go that far!
  25.     actual := aLen - curPos          // Actual is whatever is left
  26.     curPos := aLen                   // Put pointer at end
  27.   else                            // Can move the whole distance...
  28.     actual := howMany                // Actual is number requested
  29.     curPos += howMany                // Move pointer forward
  30.   endif
  31. else                           // Moving backward?
  32.   if (curPos +howMany) < 1        // Can't go that far!
  33.     actual := 1 -curPos              // Actual is whatever was left
  34.     curPos := 1                      // Put pointer at top
  35.   else                            // Can move the whole distance...
  36.     actual := howMany                // Actual is number requested
  37.     curPos += howMany                // Move pointer backward
  38.   endif
  39. endif
  40. return actual
  41.  
  42. // end of file CHP2511.PRG
  43.