background image
C H A P T E R 1 6
Find
Using the Find Service
16-17
Finding Text With a ROM_CompatibleFinder
16
The following example shows how to use the
ROM_CompatibleFinder
proto to
search for text in application data that is not soup based. The sample code
immediately following doesn't contain code that actually searches application data,
because the implementation of such a search would be specific to the data type
used to store the application data.
MyAppplicationBase.Find:=
func(what, results, scope, statusView)
begin
local item, foundItems, massagedFoundItems, myFinder;
// Set the message in the Find slip.
if statusView then
statusView:SetMessage("Searching in " &
GetAppName(kAppSymbol) & $\u2026);
// MyFindMethod does the actual searching, since
// this is too app-specific to do here. It returns
// an array of all the data items that match 'what.
foundItems := MyFindMethod(what);
// Now we create an array with frames of the form
// mandated for ROM_CompatibleFinder.
massagedFoundItems :=
foreach item in foundItems collect
{
// Use proto inheritance to protect data
_proto
: item,
// This is seen by the user in the Overview
// (pretend our data is frames w/'name slots)
title
: item.name,
// We may add any other slots here our
// methods may want later
};
// Construct the finder frame.
myFinder :=
{_proto: ROM_CompatibleFinder, // For non-soup data
owner: self,// View receiving ShowFoundItem message
title: "My App",
items: massagedFoundItems,
findType : 'text,
findWords: :MyStringSplittingFn(what),
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна