Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Locate text in a .DBF file

Aug
1,929
71
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
 
Back
Top