Find
 

 < Home   < Developers   < Development Support   < Documentation

10 Find


 Table of Contents  |  < Previous  |  Next >  |  Index
   
   

Title -
Palm OS® Programmer's API Reference

Part I: User Interface

10 Find

Find Functions

FindDrawHeader

FindGetLineBounds

FindSaveMatch

FindStrInStr

       

This chapter describes the global find facility API declared in the header file Find.h.

Find Functions

FindDrawHeader

Purpose

Draw the header line that separates, by application, the list of found items.

Prototype

Boolean FindDrawHeader (FindParamsPtr findParams, Char const* title)

Parameters

-> findParamsPointer to the sysAppLaunchCmdFind launch code's parameter block.
-> titleString to display as the title for the current application.

Result

Returns true if Find screen is filled up. Applications should exit from the search if this occurs.

Comments

Call this function once at the beginning of your application's response to the sysAppLaunchCmdFind launch code. This function draws a header for your application's Find results. The header separates the search results from your application with the search results from another application.

If your application searches multiple databases, you may also use FindDrawHeader as a separator between databases.

FindGetLineBounds

Purpose

Returns the bounds of the next available line for displaying a match in the Find results dialog.

Prototype

void FindGetLineBounds (const FindParamsType *findParams, RectanglePtr r)

Parameters

-> findParamsPointer to the sysAppLaunchCmdFind launch code's parameter block.
<- rThe bounds of the area that should contain the next line of results.

Result

Returns nothing.

FindSaveMatch

Purpose

Saves the record and position within the record of a text search match. This information is saved so that it's possible to later navigate to the match.

Prototype

Boolean FindSaveMatch (FindParamsPtr findParams, UInt16 recordNum, UInt16 pos, UInt16 fieldNum, UInt32 appCustom, UInt16 cardNo, LocalID dbID)

Parameters

-> findParamsPointer to the sysAppLaunchCmdFind launch code's parameter block.
-> recordNumRecord index. This parameter sets the recordNum field in the sysAppLaunchCmdGoto's parameter block.
-> posOffset of the match string from start of record. This parameter sets the matchPos field in the sysAppLaunchCmdGoto's parameter block.
-> fieldNumField number that the string was found in. This parameter sets the matchFieldNum field in the sysAppLaunchCmdGoto's parameter block.
-> appCustomExtra data the application can save with a match. This parameter sets the matchCustom field in the sysAppLaunchCmdGoto's parameter block.
-> cardNoCard number of the database that contains the match. This parameter sets the dbCardNo field in the sysAppLaunchCmdGoto's parameter block.
-> dbIDLocal ID of the database that contains the match. This parameter sets the dbID field in the sysAppLaunchCmdGoto's parameter block.

Result

Returns true if Find screen is filled up. Applications should exit from the search if this occurs.

Comments

Call this function when your application finds a record with a matching string (FindStrInStr or TxtFindString returns true). This function saves the information you pass. If the user clicks this selection in the Find results dialog, the information is retrieved and used to set up the sysAppLaunchCmdGoto launch code's parameter block.

You can use the appCustom field for any application-specific data that might be needed to navigate to the record if the user selects it. It's common for localizable applications to set appCustom to the length of the matching string because the global find facility cannot correctly determine the length of the matching string on systems with multi-byte character sets. In some character encodings, one character may be accurately represented as either a single-byte character or a multi-byte character. The TxtFindString function accurately matches single-byte characters against their multi-byte equivalents and returns the length of the matching string. If you pass TxtFindString's return value as the appCustom parameter to FindSaveMatch, the matchCustom field of the sysAppLaunchCmdGoTo parameter block contains the length of the matching string.

If your application requires more custom information, you can store the information in a feature and store the feature number in the appCustom field. See the "Feature Manager" chapter for more information.

FindStrInStr

Purpose

Perform a case-blind prefix search for a string in another string. This function assumes that the string to find has already been normalized for searching.

Prototype

Boolean FindStrInStr (Char const *strToSearch, Char const *strToFind, UInt16 *posP)

Parameters

-> strToSearchString to search.
-> strToFindNormalized version of the text string to be found.
<- posPIf a match is found, contains the offset of the match within strToSearch.

Result

Returns true if the string was found. FindStrInStr matches the beginnings of words only; that is, strToFind must be a prefix of one of the words in strToSearch for FindStrInStr to return true.

Comment

Don't use this function on systems that support the text manager. Instead, use TxtFindString, which performs searches on strings that contain multi-byte characters and returns the length of the matching text.

For backward compatibility with systems that don't support the text manager, use TxtGlueFindString, found in the PalmOSGlue library. TxtGlueFindString calls TxtFindString if the text manager is present, or FindStrInStr if it is not present. For more information, see Chapter 76, "PalmOSGlue Library."

The method by which a search string is normalized varies depending on the version of Palm OS® and the character encoding supported by the device. The string passed to your application in the strToFind field of the sysAppLaunchCmdFind launch code parameter block has already been normalized. It can be passed directly to FindStrInStr, TxtFindString, or TxtGlueFindString. If you need to create your own normalized search string, use TxtGluePrepFindString, also in the PalmOSGlue library.