Printing All Names Beginning with "K"

Slow Way

The approach uses only a validTest to find names beginning with "K". The cursor must iterate through every single name in the soup, applying the validTest to each one. The example took approximately 9 seconds to execute.

soup := GetUnionSoup("Names");
curs := soup:Query(
   {
      indexPath: 'sortOn, 
      validTest: 
         func(e) 
         begin
            return BeginsWith(e.sortOn, "k");
         end
   });
e := curs:Entry();
while e do begin
   Print(e.sortOn);
   e := curs:Next();
end;
"Keohane"
"Kohnlenberger"
"Kollmyer"
"Kuang"

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

Last modified: 1 DEC 1996