Re: UDF's in FoxPro indexes by Jeroen
Jeroen
Sat Jun 26 16:11:51 CDT 2004
On Fri, 25 Jun 2004 10:13:06 -0700, "Carlo Stonebanks"
<CarloStonebanks@discussions.microsoft.com> wrote:
>I am trying to share foxPro files with Clipper apps using CDX-compatible drivers.
The only solution that i could find was to patch the runtime and
development libarry's to 'rename' the function descend() to something
else (in my case I made it desqend())
Somehow this also changes the option word descending to desqending so
now I start every program file with:
#define descending desqending
and make sure I use the complete 'descending' text in the commands:
select ..., set inde to, use ... descending, etc
After finding out the correct locations in the library's it runs like
a charm.
*------------------
* FUNCTION to make a descending index
* make sure all occurrences of 'DESCENDING' in vfp*.* are patched
* to e.g. 'DESQENDING' to remove the internal descend function
* VFP7.EXE offset #F378B change 44 to 51
* VFP7R.DLL offset 0x2FE147 change 44 to 51
*!* Jakub Ridel schrieb in Nachricht
<8chgt6$1re2$1@news.vol.cz>...
*!* >I use Cilpper 5.2 and Six Driver 3. I have complicated
indexes with keys
*!* >like
*!* > "string+str(number,6)+descend(string)". I need to access
them from Windows.
*!* >But common FoxPro 2.6 ODBC driver isn't able to read them.
*!* descend is something you need to write in FoxPro.
*!* It makes xor(string, 0xFE) and nothig more.
PARAMETERS lcTekst
* try simple xor 0xFF && doesnt work, neither 0xFE
PRIVATE lcRes,lnTel,lnAsc
lcRes=''
*lcTekst=TRANSFORM(lcTekst) && hope this works...
FOR lnTel=1 TO LEN(lcTekst)
lnAsc=ASC(SUBSTR(lcTekst,lnTel,1))
IF lnAsc=0
lcRes=lcRes+CHR(0)
ELSE
lcRes=lcRes+CHR(256-lnAsc)
ENDIF
*lcRes = lcRes + CHR(BITXOR(ASC(SUBSTR(lcTekst,lnTel,1)),0xFF))
ENDFOR
RETURN lcRes
*----------------------------
> The problem is that the index expressions include function names that are incompatible with FoxPro.
>Some are easy to fix - the Pad() function can be replaced with PadL() for example. However, the Descend() function
>allows mixed ascend/descend indexes, such as INDEX ON CUSTCODE + DESCEND(INV_DATE) TO...
>
>As you can guess, this will produce a sort order of ascending costmer codes, but descending invoice dates.
>
>I know how to reproduce the functionality of Descend() in FoxPro by creating a UDF, but I also need to know how to make sure that it is always available every time VFP8 runs - without the user having to explicitly load any procedure files. What is the best practice for this? Also, is it possible to create a DLL or something containing UDF's for index expressions athat can be attached to an ODBC, OLE DB or ADO objects so that other apps using an instance of the FoxPro data engine can also automatically have access to these functions?
>
>TIA
>
>Carlo