Dec 222017
Uses Low Level Clipper Functions to Find a Text String in any File.
File FSRCH.ZIP from The Programmer’s Corner in
Category Dbase Source Code
Uses Low Level Clipper Functions to Find a Text String in any File.
File Name File Size Zip Size Zip Type
READ.ME 1522 728 deflated
SEARCH.PRG 2446 947 deflated

Download File FSRCH.ZIP Here

Contents of the READ.ME file


This demo program uses a function called FSEARCH() to find strings
within a file. The demo simulates "locate" and "continue" using the
Clipper low level file functions.

FSEARCH() works by reading "blocks" of data into a buffer, and then
searching the block for the specified string. If the string is not
found then the file pointer is repositioned (len(string) - 1) bytes
back from the end of the last block before the next block is read
into a buffer and searched. This technique allows FSEARCH() to find
strings that are spread across the boundry between blocks.

If successful, FSEARCH() sets the file pointer to the start of the
string and returns the string location in number of bytes from the
beginning of file. Otherwise, FSEARCH() returns -1.

Search speed is a function of the size of the block read into memory
and searched (the block size in this demo is set to 16k). For example,
the search time using a 2k block is approximately 4 times longer than
searching with a 16k block. You should experiment with block size to
balance search time against available memory. The upper limit to the
block size is fixed by Clipper at 64999 bytes by my tests (try the
expression, mvar = space(65000) then ?len(mvar) ). This is due to
"overhead" according to Nantucket product support.

Dave Benson
2nd Story Computing

 December 22, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>