|
|
SEARCHING
IN OPENSCRIPT
If you want to control the Search features of FTS Pro with OpenScript,
you have the three methods [listed at the bottom] available to use.
FTS_MENU
Regardless of which of the three methods you choose, you may want
to prevent the Search menu from appearing at Reader level. To do this,
set the property fts_Menu
to "OFF". This is a book property and must be set for each book
in which you want this feature to occur. Note that this setting is also
available from the configuration settings screen.
Where does the .FTS file need to be placed?
The .FTS file must be in the SAME directory as the book currently
loaded, or in a subdirectory called FTS.
FTS_INDEXBOOKNAME
In the event you have created several index files for different sets
of books, you can specify which .FTS file to load. To do this, you must
set a property called fts_IndexBookName
to the name of the index file. This is a book property and must be set
for each book in which you want this feature to occur. Note that this setting
is also available from the configuration settings screen.
__________________________________________________
To request a list of all [or some] words contained in the index file,
you can call the function:
fts_AllText([letter])
Sample:
someWords
= fts_AllText("F")
LETTER:
The Letter parameter must be a single character. If specified, only
words beginning with that character will be returned.
If Null is passed - all words will be returned.
If the index file contains more than 64k of words, only the first
64k will be returned. This list is returned in alphabetical order.
If the index file can't be found, the following value is returned:
"Can't
Find Index - ERROR"
__________________________________________________
To perform a search without showing the search interface, use the
following function:
fts_SearchForText(<searchText>,[logic],[control],[layout])
Sample:
results
= fts_SearchForText("cat","and","whole")
logic = "AND"
or "OR"
control = "WHOLE"
or "PARTIAL"
LOGIC:
You can specify that - in order to make a match - all of the words you
are looking for must be found. To do this you would use the AND logic
value. Alternately, you can specify that only some of the words you are
looking for must be found by using the OR logic value. If Null is passed,
AND is used as a default value.
CONTROL:
You can specify that you are looking for whole words by using the WHOLE
control value. Alternately, you can specify that you want all matches returned
- even if not whole words, by using the PARTIAL control value.
Returned to you is a CRLF separated list of pages that match your
search criteria. Below is a sample of the return text.
"Making
an Apple Pie",4,deserts.tbk
"Cooking without
salt, sugar or flavor",110,diets.tbk
Each
line contains 3 items.
1. The first item is either the actual name of the page or the
Title if one was specified
with the fts_PageName property.
Note that this item
is quoted because it is possible for the
item to contain a comma
which would cause parsing problems.
2. The second is the Page ID number that the match was found on.
3. The last is the actual name of the book.
LAYOUT:
The layout parameter has 3 possible values.
1. If set to "1", the data will be returned with ONLY ID
numbers
2. If set to "2", the data will be returned in raw format
of:
Making
an Apple Pie<tab>4,deserts.tbk
3. If the value of Layout is ANY OTHER value including NULL,
the data will be returned
back in the standard format of:
"Making
an Apple Pie",4,deserts.tbk
If no match was made, NULL
is returned.
If the index file can't be found, the following value is returned:
"Can't
Find Index - ERROR"
__________________________________________________
If you want to use the Search Interface - but activate if from Script
instead of having the user manually open it from the Search menu, you can
use this Handler:
send
fts_SearchForText <searchText>,[logic],[control],[layout]
Notice that the Handler name and the Function name (above) are identical.
The parameters are also identical. When using this Handler, any parameters
you specify will be the default values the user sees when the interface
is displayed. |
|