>> Hi All,
>> Any idea how to create a so called "inverted index".
>> dBASE/FoxPro code or pseudo code would be great. Also a
>> shareware/PD/freeware program will do.
>Don't know if it will help, but in Clipper you do it by using the descend()
>function. I don't believe the function exists in dBase III+; not sure about
>Fox.
>Larry
>-----------------------------------------------------------------------------
>Colebrook, NH 03576-0158 CIS 72427,2567 fax +1 603 237 8430
I believe that you can create an inverted index by replacing each character
of the index expression with CHR(255-ASC(m.the_character)). This will
'invert' the expression. Numbers, Dates, Logicals, etc will have to be
handled differently... The following function should do the trick.
FUNCTION DESCEND
PARAMETERS cOldKey
PRIVATE cNewKey
cNewKey = ""
FOR X = 1 TO LEN(cOldKey)
cNewKey = cNewKey + CHR(255-ASC(SUBSTR(cOldKey,X,1)))
ENDFOR
RETURN cNewKey
You could also use a CHRTRAN() function in FoxPro, something like...
FUNCTION Descend
PARAMETERS ctheExpr
RETURN CHRTRAN(ctheExpr,'ABCDEFGHI','IHGFEDCBA')
The second and third parameters of CHRTRAN may need to be 256 characters
long with the entire set inverted in one of the two expressions. (I used a
simple set for purposes of illustration).
One benefit of using the second example over the first is that it can be
incorporated as part of an index without having to call an external
function. It will operate significantly faster as a result, however, I'm
not sure how the expression will work if you include the entire ASCII set
within the string. You will need to consider that the string delimiters
are also part of the ASCII set and you will probably have to split the
expression and add to get a working function.
Any suggestions or comments are welcome...
--
Mark T. Boyer
Oak Ridge, Tennessee