![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
perl Makefile.PL make make install
This will copy Xbase.pm to the perl library directory provided you have the permissions to do so. To use the module in your programs you will use the line:
use Xbase;
If you cannot install it in the system directory, put it whereever you like and tell perl where to find it by using the following in the beginning of your script:
BEGIN { unshift(@INC,'/usr/underprivileged/me/lib'); } use Xbase;
$database = new Xbase;
This will create an object $database
that will be used to
interact with the various methods the module provides.
$database->open_dbf($dbf_name, $idx_name);
Associates the DBF file and optionally the IDX file with the object. It opens the files and if a associated MEMO file is present automatically opens it. Only Foxpro Memo files are currently supported and assumes the same filename as the DBF with a FPT extension.
print $database->dbf_type;
Returns a string telling you if the xbase file opened is DBF3, DBF4 or FOX
print $database->last_update;
Returns a date string telling you when the database was last updated.
$end=$database->lastrec;
Returns the record number of the last record in the database file.
$database->dbf_stat;
This prints out on to STDOUT a display of the status/structure of the database. It is similar to the xbase command DISPLAY STATUS. Since it prints field names and structure it is commonly used to see if the module is reading the database as intended and finding out the field names.
$database->idx_stat;
Prints on to STDOUT the status information of an open IDX file.
$database->go_top;
Moves the record pointer to the top of the database. Physical top of database if no index is present else first record according to index order.
$database->go_bottom;
Moves the record pointer to the bottom of the database. Physical bottom of database if no index is present else last record according to index order.
$database->go_next;
Equivalent to the xbase command SKIP 1 which moves the record pointer to the next record.
$database->go_prev;
Equivalent to the xbase command SKIP -1 which moves the record pointer to the previous record.
$stat=$database->seek($keyvalue);
This command positions the record pointer on the first matching record that has the key value specified. The database should be opened with an associated index. Seek without an available index will print an error message and abort. The return value indicates whether the key value was found or not.
$current_rec=$database->recno;
Returns the record number that the record pointer is currently at.
if ($database->bof) { print "At the very top of the file \n"; }
Tells you whether you are at the beginning of the file. Like in xbase it is not true when you are at record number one but rather it is set when you try to $database->go_prev when you are at the top of the file.
print $database->get_field("NAME");
Returns as a string the contents of a field name specified from the current record. Using the pseudo field name _DELETED will tell you if the current record is marked for deletion.
@fields = $database->get_record;
Returns as an array all the fields from the current record. The fields are in the same order as in the database.
$database->close_dbf;
This closes the database files, index files and memo files that are
associated with the $database
object with
$database->open_dbf
I request that if you use this module at a web site to make a link to http://eewww.eng.ohio-state.edu/~pereira/software/xbase/
This is just so that others might find it. This is however not required of you.
Pratap Pereira pereira@ee.eng.ohio-state.edu
Fixed problem with GO_PREV & GO_NEXT after SEEK. Fixed problem with parsing headers of dbfs with record length > 255. Added Memo file support.
Fixed problem with certain IDX failing completely, was a stupid indexing mistake.
Fixed field length inconsistency errors by changing way header is decoded. Should work with more xbase variants. (Dick Sutton & Andrew Vasquez)
Added binmode command to file handles to support Windows NT
Made documentation in pod format, installation automated. Fixed problem with deleted status being improperly read (Chung Huynh). Renamed to Xbase (previously xbase) to be consistent with other perl modules. Released in CPAN. Prettied up dbf_stat output (Gilbert Ramirez).
$CommentsMailTo = "perl5@dcs.ed.ac.uk"; include("syssies_footer.inc");?>