- Aug
- 2,056
- 83
Code:
::+-----------------------------------------------------------------------+
::| DBF_LOCATE.BTM |
::| Locate text in a .DBF file |
::| Requires DBF PlugIn available from |
::| https://sites.google.com/site/jlcprogrammingstuff/home/tcc/dbf-plugin |
::| |
::| Joe Caverly |
::| February 14, 2012 |
::| |
::| USAGE: DBF_LOCATE text2searchfor myfile.dbf |
::+-----------------------------------------------------------------------+
@setlocal
@echo off
if not plugin dbf plugin /l dbf
iff %# eq 2 then
set searchTerm=%1
set thedbf=%2
iff not exist %thedbf then
echo The file %thedbf does not exist
goto eoj
endiff
else
echo USAGE: DBF_LOCATE text2searchfor myfile.dbf
goto eoj
endiff
echo Searching for [%searchTerm]
set LastRecord=%@reccount[%thedbf]
do RecordNumber=1 to %LastRecord
set therecord=%@record[%thedbf,%RecordNumber]
set occurances=%@index[%@quote[%therecord],%searchTerm,0]
iff %occurances gt 0 then
echo Record %@formatn[3.0,%RecordNumber]:` `%therecord
endiff
enddo
:eoj
plugin /u dbf
endlocal