8 Dec 11 1:41
String limits were smaller in FP2.x than what we enjoy today in VFP. The string limit was 16K if I recall correctly (which may very well not be the case).
Ah, the old days, I remember FPD 2.6 had a max limit of 1KB in a parameter. Oh well, that's not the subject at hand...
Today's VFP 9.0 appears to have a maximum memo field length of 16MB but I determined that by experimentation, I didn't find it in the VFP system capacities chart. I don't know what the maximum size is for your version, but the code below assumes it is similar.
Presuming your version can use SUBSTR() up to the maximum size of your memo fields, then this should work.
PARAMETERS cSearchExp, cSearchFld, nBlockSize
PRIVATE nMemoLen, nBlock, cChunk, nBeg, nEnd, nMatches
nMemoLen = LEN(EVALUATE(cSearchFld))
nBlock = IIF(TYPE("nBlockSize")="N", nBlockSize, 15000) && optional, set 15000 as default block size
cChunk = ""
nBeg = 0
nMatches = 0
IF nBlock > LEN(cSearchExp)
DO WHILE nBeg + LEN(cChunk) <= nMemoLen
IF nBeg = 0
nBeg = 1
nBeg = nEnd - (LEN(cSearchExp)-1)
nEnd = MIN(nBeg + nBlock - 1, nMemoLen)
cChunk = SUBSTR(EVALUATE(cSearchFld), nBeg, nBlock - 1)
nMatches = nMatches + OCCURS(cSearchExp, cChunk)
? "You specified a search block size smaller than the search expression."
This is an example using myOccurs(). Remember to include the alias if you are not in that work area.
? myOccurs("text here", "MyMemoFld", 5000)
* if 3rd parm not sent, default is 15000