xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

SET SCOPE

Changes the top and/or bottom scope for navigating in the controlling index.

Syntax

SET SCOPE TO [<topScope> [, <bottomScope>]]

Arguments

TO <topScope>
This is an expression whose value is used to define the top scope, or top boundary, for indexed database navigation. Its data type must match with the data type of the index expression of the controlling index. Alternatively, <topScope> can be a code block that must return a value of the correct data type.

If <bottomScope> is omitted and <topScope> is defined, it is used for both, the top and bottom scope.

SET SCOPE TO with no argument clears a defined scope.

, <bottomScope>
This is the same like <topScope>, except that the bottom scope, or bottom boundary is defined.

Description

The SET SCOPE command defines or clears the top and bottom scope for indexed database navigation. The top and bottom scope values define the range of values valid for navigating the record pointer within the controlling index.

When a scope is set, the GO TOP command is equivalent to SEEK <topScope>, while GO BOTTOM is the same as SEEK <bottomScope> LAST.

Attempting to move the record pointer before <topScope> does not change the record pointer but causes function BoF() to return .T. (true).

When the record pointer is moved beyond <bottomScope>, it is advanced to the ghost record (Lastrec()+1) and function EoF() returns .T. (true).

Info

See also:BoF(), EoF(), Found(), GO, OrdKey(), OrdScope(), SET INDEX, SET ORDER, SKIP
Category: Database commands , Index commands
Header:Ord.ch
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates indexed database navigation
// restricted by scopes.

   #include "Ord.ch"

   PROCEDURE Main
      USE Customer

      INDEX ON Upper(LastName) TO Cust01
      GO TOP
      ? Recno(), Bof(), Eof(), Lastname // result:   25 .F. .F. Abbey

      GO BOTTOM
      ? Recno(), Bof(), Eof(), Lastname // result:  127 .F. .F. Zwillick

      SET SCOPE TO "E", "G"
      GO TOP
      ? Recno(), Bof(), Eof(), Lastname // result:  558 .F. .F. Earley

      SKIP -1
      ? Recno(), Bof(), Eof(), Lastname // result:  558 .T. .F. Earley

      GO BOTTOM
      ? Recno(), Bof(), Eof(), Lastname // result: 1660 .F. .F. Gwinnell

      SKIP
      ? Recno(), Bof(), Eof(), Lastname // result: 1996 .F. .T.
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe