home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR19 / SNIP0693.ZIP / FILLBROW.PRG < prev    next >
Text File  |  1993-04-29  |  2KB  |  75 lines

  1. FUNCTION FillBrowse( oBrowse )
  2. /*
  3. Last modified: 04-27-93 09:37am
  4. Forces all data rows in a tbrowse display to be filled with data
  5. (provided enough is available in the data source).  The browse
  6. cursor will stay with the current record even if the record's
  7. row position changes.
  8.  
  9. Authors: Todd MacDonald and Shane Hall
  10. Recommended usage:
  11.   dispbegin()
  12.   FillBrowse( oBrowse )
  13.   dispend()
  14. */
  15.  
  16. LOCAL nMoved := 0  // keeps track of where original record is
  17. LOCAL nScroll      // number of records to scroll up
  18. LOCAL n            // loop counter
  19. // save autoLite status and turn off hilite to prevent "sticky"
  20. // cursor and speed up stabilization.
  21. LOCAL lSavAutoL  := oBrowse:autoLite
  22.  
  23.      oBrowse:autoLite := .f.
  24.      oBrowse:deHilite()
  25.      oBrowse:ForceStable()        // WHILE !oBrowse:stabilize(); END
  26.  
  27.      // try to move the pointer to the bottom row of the display
  28.      WHILE oBrowse:rowPos < oBrowse:rowCount .and. !oBrowse:hitBottom
  29.           oBrowse:down()
  30.           oBrowse:ForceStable()      // WHILE !oBrowse:stabilize(); END
  31.           nMoved++
  32.      END
  33.  
  34.      // if we hit bottom, then there are 1 or more blank rows
  35.     IF oBrowse:hitBottom
  36.           // calculate number of records to scroll up past the top row
  37.           nScroll := oBrowse:rowCount - oBrowse:rowPos
  38.           // keep track of where the original record is
  39.           nMoved -= oBrowse:rowPos
  40.           // go to the top row
  41.           oBrowse:rowPos := 1
  42.  
  43.           // attempt to scroll up the appropriate number of records
  44.           FOR n := 1 TO nScroll
  45.                oBrowse:up()
  46.                oBrowse:ForceStable()      // WHILE !oBrowse:stabilize(); END
  47.                IF !oBrowse:hitTop
  48.                     nMoved--
  49.                ELSE
  50.                     EXIT
  51.                ENDIF
  52.           NEXT n
  53.  
  54.           // put pointer back on original record
  55.           FOR n := 1 TO -nMoved
  56.                oBrowse:down()
  57.           NEXT n
  58.  
  59.      // we didn't hit bottom so the display is already filled
  60.      ELSE
  61.  
  62.           // put pointer back on original record
  63.           FOR n := 1 TO nMoved
  64.                oBrowse:up()
  65.           NEXT n
  66.  
  67.      ENDIF
  68.  
  69.      oBrowse:ForceStable()             // WHILE !oBrowse:stabilize(); END
  70.      // turn hilite on and restore autoLite status
  71.      oBrowse:hilite()
  72.      oBrowse:autoLite := lSavAutoL
  73.  
  74. RETURN NIL
  75.