XBase

XBase is a Perl module for reading and writing the dbf files.
Download

XBase Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Jan Pazdziora
  • Publisher web site:
  • http://search.cpan.org/~janpaz/Apache-OutputChain-0.11/MakeCapital.pm

XBase Tags


XBase Description

XBase is a Perl module for reading and writing the dbf files. XBase is a Perl module for reading and writing the dbf files.SYNOPSIS use XBase; my $table = new XBase "dbase.dbf" or die XBase->errstr; for (0 .. $table->last_record) { my ($deleted, $id, $msg) = $table->get_record($_, "ID", "MSG"); print "$id:t$msgn" unless $deleted; }This module can read and write XBase database files, known as dbf in dBase and FoxPro world. It also reads memo fields from the dbt and fpt files, if needed. An alpha code of reading index support for ndx, ntx, mdx, idx and cdx is available for testing -- see the DBD::Index(3) man page. Module XBase provides simple native interface to XBase files. For DBI compliant database access, see the DBD::XBase and DBI modules and their man pages.The following methods are supported by XBase module:General methodsnewCreates the XBase object, loads the info about the table form the dbf file. The first parameter should be the name of existing dbf file (table, in fact) to read. A suffix .dbf will be appended if needed. This method creates and initializes new object, will also check for memo file, if needed.The parameters can also be specified in the form of hash: value of name is then the name of the table, other flags supported are:memofile specifies non standard name for the associated memo file. By default it's the name of the dbf file, with extension dbt or fpt.ignorememo ignore memo file at all. This is usefull if you've lost the dbt file and you do not need it. Default is false.memosep separator of memo records in the dBase III dbt files. The standard says it should be "x1ax1a". There are however implamentations that only put in one "x1a". XBase.pm tries to guess which is valid for your dbt but if it fails, you can tell it yourself.nolongchars prevents XBase to treat the decimal value of character fields as high byte of the length -- there are some broken products around producing character fields with decimal values set. my $table = new XBase "table.dbf" or die XBase->errstr; my $table = new XBase "name" => "table.dbf", "ignorememo" => 1;recompute_lastrecno forces XBase.pm to disbelieve the information about the number of records in the header of the dbf file and recompute the number of records. Use this only if you know that some other software of yours produces incorrect headers.closeCloses the object/file, no arguments.createCreates new database file on disk and initializes it with 0 records. A dbt (memo) file will be also created if the table contains some memo fields. Parameters to create are passed as hash.You can call this method as method of another XBase object and then you only need to pass name value of the hash; the structure (fields) of the new file will be the same as of the original object.If you call create using class name (XBase), you have to (besides name) also specify another four values, each being a reference to list: field_names, field_types, field_lengths and field_decimals. The field types are specified by one letter strings (C, N, L, D, ...). If you set some value as undefined, create will make it into some reasonable default. my $newtable = $table->create("name" => "copy.dbf"); my $newtable = XBase->create("name" => "copy.dbf", "field_names" => , "field_types" => , "field_lengths" => , "field_decimals" => );Other attributes are memofile for non standard memo file location, codepage to set the codepage flag in the dbf header (it does not affect how XBase.pm reads or writes the data though, just to make FoxPro happy), and version to force different version of the dbt (dbt) file. The default is the version of the object from which you create the new one, or 3 if you call this as class method (XBase->create).The new file mustn't exist yet -- XBase will not allow you to overwrite existing table. Use drop (or unlink) to delete it first.dropThis method closes the table and deletes it on disk (including associated memo file, if there is any).last_recordReturns number of the last record in the file. The lines deleted but present in the file are included in this number.last_fieldReturns number of the last field in the file, number of fields minus 1.field_names, field_types, field_lengths, field_decimalsReturn list of field names and so on for the dbf file.field_type, field_length, field_decimalFor a field name, returns the appropriate value. Returns undef if the field doesn't exist in the table. Requirements: · Perl


XBase Related Software