background image
C H A P T E R 1 1
Data Storage and Retrieval
Using Newton Data Storage Objects
11-47
Sending the
Reset
message to the cursor positions it at the first valid entry in
index order. In this case, the first entry is
"noun"
because the entries are sorted in
descending alphabetical order.
The
GoToKey
cursor method steps through the set of valid entries in index order
until it finds the first entry having a specified key value. If the specified key value is
not found, this method returns the next valid entry found after the specified index
position. Thus, sending the
GotoKey("az")
message to this cursor returns the
value
"axe"
because it's the first valid entry that appears in the index after the
unoccupied
"az"
position.
Sending the
GotoKey("a")
message to this cursor returns the value
nil
because
this message positions the cursor beyond the end of the range of valid entries
defined by the query that generated the cursor.
Figure 11-7 illustrates that specifying a
beginExclKey
value of
"b"
excludes
from consideration every entry beginning with a letter that comes after
"b"
in the
reverse alphabet; that is, this
beginExclKey
value causes the valid range of
entries to include only entries beginning with
"a"
. As a result, sending the
GotoKey("n")
message causes this cursor to return the value
"axe"
because it
is the first valid entry appearing in the index after the
"n"
position.
Note
The sort order for symbol-based indexes is the ASCII order of the
symbol's lexical form. This sorting behavior is made available in
NewtonScript by the
SymbolCompareLex
global function.
Figure 11-7
Specifying ends of a descending index
Querying on Multiple-Slot Indexes
11
Before reading this section, you should understand the contents of "Querying on
Single-Slot Indexes" beginning on page 11-39.
Descending key order
beginExclKey
cursor:GoToKey("n");
Valid subrange
Z
"noun"
"name"
B
N
"axe"
"able"
A
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна