moveBy method

int moveBy(
  1. int distance
)

Implementation

int moveBy(int distance) {
  var theResult = 0;
  var dist = distance;

  int scrollForward() {
    var result = 0;
    _bof = false;
    while (dist > 0 && !_eof) {
      if (_activeRecord < _recordCount - 1) {
        _activeRecord++;
        dist--;
        theResult++;
      } else {
        if (getNextRecord()) {
          dist--;
          result--;
          theResult++;
        } else {
          _eof = true;
        }
      }
    }
    return result;
  }

  int scrollBackward() {
    checkBiDirectional();
    var result = 0;
    _eof = false;
    while (dist < 0 && !_bof) {
      if (_activeRecord > 0) {
        _activeRecord--;
        dist++;
        theResult--;
      } else {
        if (getPriorRecord()) {
          dist++;
          result++;
          theResult--;
        } else {
          _bof = true;
        }
      }
    }
    return result;
  }

  checkBrowseMode();
  doBeforeScroll();
  if (dist == 0 || (dist > 0 && _eof) || (dist < 0 && _bof)) {
    return 0;
  }
  var scrolled = 0;
  try {
    if (dist > 0) {
      scrolled = scrollForward();
    } else {
      scrolled = scrollBackward();
    }
  } finally {
    dataEvent(TDataEvent.deDataSetScroll, scrolled);
    doAfterScroll();
  }
  return theResult;
}