background image
C H A P T E R 1 6
Find
16-18
Using the Find Service
// We may also add slots here...
};
// Append myFinder frame to system's results array
AddArraySlot(results, myFinder);
end;
Implementing the DateFind Method
16
Date-based searches have a lot in common with their text-based counterparts; in
fact the only significant difference between these two operations is the search
criteria. Rather than matching a text string, the
DateFind
method tests items
against a time value according to the value of the
findType
parameter. This
parameter indicates whether the search should include results for items dated on,
after, or before a specified date.
You can simplify the implementation of date-based searches by time-stamping your
application's data when it is stored. If you store application data as frames that hold
the time they were created or modified in a particular slot, the
DateFind
method
simply tests the value of this slot to accept or reject the entry.
The sample code immediately following shows the implementation of a typical
DateFind
method using the
ROM_SoupFinder
proto. This code assumes that
soup entries have a
timeStamp
slot:
MyApplicationBase.DateFind :=
func(findTime, findType, results, scope, statusView)
begin
local myCursor ;
local querySpecFrame;
local querySpec;
local ourFinder;
local mySoup;
constant kOneDay := 60*24;
// report status to the user
if statusView then
statusView:SetMessage("Searching in " &
GetAppName(kAppSymbol) & $\u2026);
// Get the soup
mySoup:= RegUnionSoup(kAppSymbol, kSoupDef);
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна