Category : Files from Magazines
Archive   : DBMS0291.ZIP
Filename : FOXPRO3.FEB

 
Output of file : FOXPRO3.FEB contained in archive : DBMS0291.ZIP


PROCEDURE FindStr.prg
************************************************************
* Program ...: FindStr.prg
* Author : P. L. Olympia & Kathy Cea
* Purpose....: Searches a text file for the Nth occurrence of
* : a specified string using FoxPro memo field
* : commands/functions
* Syntax ....: DO FindStr WITH , ,
* Notes .....: Assumes .dbf in current area has memo field
* : called MemFld
************************************************************
PARAMETERS string, txtfile, Noccur

*-- Make sure file exists

IF !FILE((txtfile))
? "Can't seem to find " + txtfile
RETURN
ENDIF

Noccur = IIF(Noccur < 1, 1, Noccur) && Can't be < 1

*-- Load the file to the memo field
APPEND MEMO memfld FROM (txtfile) OVERWRITE

*-- Search the memo field for the string
start = ATC(string, memfld, Noccur)
IF start = 0
? string + 'not found'
ELSE
* Display string highlighted in window
long = start + LEN(string)
MODIFY MEMO memfld NOEDIT RANGE start, long
ENDIF
RETURN