Product: | Platform: | Area: | Version: |
INM V12 Database for Director | Windows, Macintosh | Searching and sorting | 3.x Regular & Light |
Summary
It is possible to makes searches in a V12 Database file that are performed as the user types. This technotes explain how to implement a "MS-Help" search style to your movie.
Example
The first thing to do is to open the database where the search will be performed. The movie stage should contain at least one field to show the values in which the search is being done, and another one where the user will be typing.
When a user types into the search field, use the "on KeyDown" handler to trap what the user types. Each time the user types a new character, call another handler that should look like the following one, where "x" represents the complete string contained in the field where the user is typing.
on LookInDB x
if (length(x)=0) then
mSelectAll(gTable)
else
mSetCriteria(gTable, "Title", "Starts", x)
end if
if CheckV12Error() then exit
mSelect(gTable)
if CheckV12Error() then exit
ShowSelection()
end
Next, the ShowSelection handler should refresh the field on screen. Here, set the gFirstRec to 1 while "kPageLength" represents the number of records that should be shown at the same time in the field list, depending of field's height.
on ShowSelection
-- Show kPageLength records of the current selection,
-- starting at record number gFirstRec
-- gTable must be valid upon entry of this handler
put mGetSelection(gTable, "LITERAL", gFirstRec, kPageLength, TAB, RETURN, "Title") into field "FoundList"
end
For a better comprehension of this example, we recommend you to download the [free] sample available below and note that the included scripts are easily reusable in any Director movie!
Sample
This sample is supported on Director 6.5 and later.
