- Aug
- 2,251
- 107
Hi,
Over at http://www.jpsoft.com/forums/showthread.php?t=1805 I wrote a batch file to read a dBASE database file.
I have modified the batch file to use the DBF Plugin, available from http://sites.google.com/site/jlcprogrammingstuff/home/tcc/dbf-plugin
The revised batch file is as follows;
Joe
Over at http://www.jpsoft.com/forums/showthread.php?t=1805 I wrote a batch file to read a dBASE database file.
I have modified the batch file to use the DBF Plugin, available from http://sites.google.com/site/jlcprogrammingstuff/home/tcc/dbf-plugin
The revised batch file is as follows;
Code:
::--------------------------------------------------------------------+
:: Open a dBASE database, display the structure, |
:: and a desired record, using the DBF Plugin |
:: Joe Caverly |
:: January 2011 |
:: |
:: USAGE: dbstruct dbfName RecordNumber |
:: |
::--------------------------------------------------------------------+
@setlocal
@echo off
::--------------------------------------------------------------------+
:: Load the DBF Plugin |
::--------------------------------------------------------------------+
if not plugin dbf plugin /l dbf
::--------------------------------------------------------------------+
:: Designate a file to use for this batch |
::--------------------------------------------------------------------+
if not exist %1 goto nofile
set dbfName=%1
::--------------------------------------------------------------------+
:: Display Structure |
::--------------------------------------------------------------------+
echo Structure for database: %dbfName
echo Number of data records: %@reccount[%dbfName]
echo Date of last update : %@lupdate[%dbfName]
echo Field Field Name Type Width Dec
do FieldNumber=1 to %@FieldCount[%dbfName]
screen %_row 0 %@format[5,%FieldNumber]
::--------------------------------------------------------------------+
:: Field Name |
::--------------------------------------------------------------------+
screen %_row 7 %@FieldName[%dbfName,%FieldNumber]
::--------------------------------------------------------------------+
:: Field Type (C, D, L, M, N) |
::--------------------------------------------------------------------+
set FieldType=%@FieldType[%dbfName,%FieldNumber]
switch %FieldType
case C
set TheType=Character
case D
set TheType=Date
case L
set TheType=Logical
case M
set TheType=Memo
case N
set TheType=Numeric
endswitch
screen %_row 19 %TheType
::--------------------------------------------------------------------+
:: Field Width |
::--------------------------------------------------------------------+
set FieldWidth=%@FieldWidth[%dbfName,%FieldNumber]
screen %_row 33 %@format[3,%FieldWidth]
::--------------------------------------------------------------------+
:: Number of decimal places (Numeric fields only) |
::--------------------------------------------------------------------+
iff %@FieldType[%dbfName,%FieldNumber] eq N then
set DecimalPlaces=%@DECIMAL[%dbfName,%FieldNumber]
iff %DecimalPlaces gt 0 then
screen %_row 40 %@format[2,%DecimalPlaces]
endiff
endiff
echo.
enddo
set TotalWidth=%@recsize[%dbfName]
screen %_row 0 ** Total **
screen %_row 31 %@format[5,%TotalWidth]
echo.
::--------------------------------------------------------------------+
:: Record Number to get |
::--------------------------------------------------------------------+
set ValidInput=N
if %2 le %@RecCount[%dbfName] set ValidInput=Y
if %2 gt 0 set ValidInput=Y
if %ValidInput eq N set Record2Get=1
if %ValidInput eq Y set Record2Get=%2
if %Record2Get gt %@RecCount[%dbfName] goto ROOR
echo.
echo Record Number: %Record2Get
::--------------------------------------------------------------------+
:: Display the record |
::--------------------------------------------------------------------+
echo %@Record[%dbfName,%Record2Get]
goto eoj
::--------------------------------------------------------------------+
:: Problem opening the database |
::--------------------------------------------------------------------+
:abort
echo Database is in use, or another error occured opening the database.
goto eoj
::--------------------------------------------------------------------+
:: File does not exist |
::--------------------------------------------------------------------+
:nofile
echo File does not exist.
echo USAGE: dbstruct x:\data\mydb.dbf
goto eoj
::--------------------------------------------------------------------+
:: Record Out Of Range |
::--------------------------------------------------------------------+
:ROOR
echo Record Out Of Range (Max. %@RecCount[%dbfName])
::--------------------------------------------------------------------+
:: End Of Job |
::--------------------------------------------------------------------+
:eoj
if plugin dbf plugin /u dbf
endlocal
Joe