DBF Plugin

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;

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

 
Hey Joe,


> I have modified the batch file to use the DBF Plugin, available
> from
> http://sites.google.com/site/jlcprogrammingstuff/home/tcc/dbf-plugin
> (https://sites.google.com/site/jlcprogrammingstuff/home/tcc/dbf-plugin)

Very nice. I've always thought that TCC should be able to work with a database, preferably (by me) dBase.

I still think adding basic dBase handling would be a great addition to TCC. Indexed database files would probably make handling long lists of data (e.g. directory lists) much faster. And it would be a great feature for marketing the next version :-)

herzliche Grüße,

Klaus Meinhard
 
Hi,
Here is a batch file to display the field data from a record in a dBase database, using the DBF Plugin. In this case, I have hard-coded record 1.

Code:
::--------------------------------------------------------------------+
::  Open a dBASE database, display the field data                     |
::  of record number 1                                                |
::  Joe Caverly                                                       |
::  January 2011                                                      |
::                                                                    |
:: USAGE: flist dbfName                                               |
::--------------------------------------------------------------------+
@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
set therecord=%@record[%dbfName,1]
do FieldNumber=1 to %@FieldCount[%dbfName]
  set FieldOffset=%@fieldoffset[%dbfname,%FieldNumber]
  set FieldWidth=%@fieldwidth[%dbfname,%FieldNumber]
  echo %@instr[%FieldOffset,%FieldWidth,%therecord]
enddo
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: flist x:\data\mydb.dbf
goto eoj
::--------------------------------------------------------------------+
:: End Of Job                                                         |
::--------------------------------------------------------------------+
:eoj
if plugin dbf plugin /u dbf
endlocal
Joe
 
Similar threads
Thread starter Title Forum Replies Date
dcantor Suggestion and request for DBF plugin Plugins 6
Joe Caverly 64-bit Plugin development using PureBasic Plugins 15
R New Plugin Plugins 0
Alpengreis elevated plugin questions Plugins 3
fpefpe utf-8 support in sdk/plugin api Plugins 4
S How to? Can @DU function in 4Utils64 plugin somehow cater for dirs with spaces? Plugins 3
vefatica Plugin access to arrays? Plugins 4
vefatica How big is a plugin's parameter buffer? Plugins 5
C @knownpath plugin Plugins 0
Charles Dye Updated OSD plugin Plugins 0
Joe Caverly C# plugin framework for JPSoft's TCC Plugins 0
dcantor Help for newest version of TEXTUTILS plugin Plugins 10
dcantor UISTUFF plugin missing help topic Plugins 12
M How to? Use SafeChars plugin... Plugins 2
dcantor Error in SAFECHARS plugin v 1.9.0 Plugins 2
dcantor Request for documentation for ISO8601 plugin Plugins 4
vefatica Possible with a plugin? Plugins 6
dcantor Inconsistency between textutils plugin and wrap utility Plugins 2
M (Stupid?) Problem with 64-bit 4Utils plugin... Plugins 3
H Latest ISO8601 plugin? Plugins 1
Charles Dye New plugin: QKeys Plugins 34
S Plugin to quickly locate all files hard linked together Plugins 5
S Documentation Plugin everything.dll Plugins 5
newbie How to? Multi-plugin installation errors, Re: FedUtils8 Plugins 7
vefatica Plugin -> thread -> Command() -> Ctrl-C? Plugins 20
Charles Dye A weirdoid plugin question Plugins 6
M SafeChars plugin misbehaving... Plugins 3
M A weird error re a plugin... Plugins 0
vefatica Plugin dilemma Plugins 2
fpefpe Documentation Plugin API/SDK Plugins 3
C Looking for Vince's old 4UTILS plugin for TCMD v8 Plugins 1
S DESKTOP plugin - anyone ? Plugins 0
C How to? a plugin to sort Outlook Express "rules" Plugins 0
M ISO Plugin: Yes, it's wonderful, but it could be yet more wonderful... Plugins 7
M The ISO plugin is wonderful, but it lacks a little something... Plugins 22
Charles Dye Beta plugin: HidePasswords Plugins 3
M ISO8601 Plugin not "reporting" errors to TCC... Plugins 4
Frank 4console plugin Plugins 4
S WAD ISO8601 Plugin Plugins 15
Joe Caverly Plugin and 64-bit TCC Plugins 3
C Problem with FixNames plugin Plugins 9
dcantor Suggestion for SafeChars plugin Plugins 7
M Charles, I just installed the "new" SafeChars plugin, ... Plugins 5
M A problem with the SafeChars Plugin... Plugins 30
S WHICHWIN (sysutils plugin) Plugins 13
M A (presumbly pretty simple) SafeChars plugin request... Plugins 2
M A "SafeChars" plugin request... Plugins 2
S ISO 8601 plugin enhancement Plugins 6
D UNKNOWN_CMD in Plugin Plugins 13
C Looking for isemailaddress[string] plugin Plugins 7

Similar threads