Important: The information in this document is obsolete and should not be used for new development.
LSearch
You can use theLSearchfunction to find a cell whose data matches data that you specify.
FUNCTION LSearch (dataPtr: Ptr; dataLen: Integer; searchProc: Ptr; VAR theCell: Cell; lHandle: ListHandle) : Boolean;
dataPtr- A pointer to the data being searched for.
dataLen- The length in bytes of the data being searched for.
searchProc- A pointer to a function to be used to compare the data being searched for with cell data. If
NIL, the Text Utilities Package functionIUMagIDStringis used.theCell- The first cell to be searched. If
LSearchfinds a match, it returns in this parameter the coordinates of the first cell whose data matches the data being searched for.lHandle- The list to be searched.
DESCRIPTION
Your application can use theLSearchfunction to search the list specified by thelHandleparameter beginning at the cell specified by the parametertheCellfor a match. IfLSearchfinds a match, it returnsTRUEand sets the parametertheCellto the coordinates of the first cell whose data matches the data specified by thedataPtranddataLenparameters. Otherwise,LSearchreturnsFALSE.The
LSearchfunction determines whether a cell's data matches the search data by calling theIUMagIDStringfunction, or the function specified by thesearchProcparameter. If that function returns 0,LSearchhas found a match; otherwise,LSearchchecks the next cell in the list.SPECIAL CONSIDERATIONS
You should not call theLSearchfunction from within an interrupt, such as in a completion routine or VBL task.ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for theLSearchfunction are
Trap macro Selector _Pack0 $0054 SEE ALSO
For examples of use of theLSearchfunction, see "Searching a List for a Particular Item" beginning on page 4-34. For information on the syntax of a custom match function, see "Match Functions" beginning on page 4-89. For information on theIUMagIDStringfunction, see Inside Macintosh: Text.