home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 25.11. ArraySkip(), a b:skipBlock function for arrays.
- 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
- */
-
- //───── NOTE: must compile with the /N option!
-
- function ArraySkip(aLen, curPos, howMany)
- /*
- General purpose array skipping function intended for
- use with TBrowse b:skipBlocks. You must pass the curPos
- parameter by reference (use the @ operator) for this
- function to work correctly with TBrowse.
- */
-
- local actual
-
- if howMany >= 0 // Moving forward?
- if (curPos +howMany) > aLen // Can't go that far!
- actual := aLen - curPos // Actual is whatever is left
- curPos := aLen // Put pointer at end
- else // Can move the whole distance...
- actual := howMany // Actual is number requested
- curPos += howMany // Move pointer forward
- endif
- else // Moving backward?
- if (curPos +howMany) < 1 // Can't go that far!
- actual := 1 -curPos // Actual is whatever was left
- curPos := 1 // Put pointer at top
- else // Can move the whole distance...
- actual := howMany // Actual is number requested
- curPos += howMany // Move pointer backward
- endif
- endif
- return actual
-
- // end of file CHP2511.PRG
-