Examples

Removing a Store While a Cursor Is Iterating

Question:
What happens to a cursor when one of the stores is removed?

Answer:
The cursor just skips over any of the entries that had been on that store. If the current entry happens to be on the removed store, then cursor:Entry() returns the next entry.

Here is how you can observe the behavior (a QuickTime movie of this example is available). Insert a card that contains some names. Then, execute the following code from the Inspector that iterates through entries until it finds one not on the internal store:

soup := GetUnionSoup("Names");
curs := soup:Query({indexPath: 'sortOn});

e := curs:Entry();
internalStore := GetStores()[0];
while e and EntryStore(e) = internalStore do begin
   e := curs:Next();
end;
Print(e);
{
   sortOn: "a",
   ...
}
Now, pull the card from the Newton and execute the Print statement again:

Print(curs:Entry());
{
   sortOn: "b",
   ...
}

An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996