background image
C H A P T E R 1 6
Find
16-16
Using the Find Service
Using Your Own Text-Searching Method
16
The following code example illustrates the kinds of tasks you must perform when
the
StandardFind
method is not used. (However, it is strongly suggested that
you use the
StandardFind
method to implement your
Find
routine, if possible.)
This example searches for text in soup-based application data using the
ROM_SoupFinder
proto:
// This routine MUST be named Find; it is called by
// the system when the user chooses Find.
MyApplicationBase.Find :=
func(what, results, scope, statusView)
begin
local myFinder;
// Report status to the user;
// note use of GetAppName and Unicode ellipsis.
if statusView then
statusView:SetMessage("Searching in " &
GetAppName(kAppSymbol)& $\u2026);
// Presume our soup def is registered,
// however, app may be closed so get our own soup.
local mySoup:= GetUnionSoupAlways("My Soup");
// Make sure a member soup exists so query won't
// fail (GetMember creates the soup if necessary).
mySoup:GetMember(GetDefaultStore());
//Retrieve entries with strings beginning with "what".
local myCursor := mySoup: Query({text: what});
// Append finder to system-supplied results array
if cursor:Entry() then
begin
myFinder :=
{
_proto: ROM_SoupFinder,
owner: self,
title:"My Application",
findType: 'text,
findWords: :MyStringSplittingFn(what),
cursor: myCursor,
};
AddArraySlot(results, myFinder);
end;
end;
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна