background image
C H A P T E R 1 6
Using the Find Service
Finding Text With a ROM_CompatibleFinder
The following example shows how to use the
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.
func(what, results, scope, statusView)
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
: item,
// This is seen by the user in the Overview
// (pretend our data is frames w/'name slots)
// 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 » при воспроизведении материала сайта ссылка обязательна