|
|||||||||
![]() |
|||||||||
|
NAMECodeBase - Perl module for accessing dBASE files
ABSTRACTThe CodeBase module provides a Perl 5 class for accessing dBASE files. It is a development of an earlier unpublished Perl 4 extension.
SYNOPSISPrograms using the CodeBase module must include the line:
use CodeBase; The functions that the module provides are listed below, grouped according to type of function.
File manipulation functions
$fh = CodeBase::open($filename, @options);
$fh = CodeBase::create($filename, @fielddefs);
$fh->DESTROY();
File information functions
$n_recs = $fh->reccount();
$recsize = $fh->recsize();
$n_fields = $fh->fldcount();
@names = $fh->names();
$type = $fh->type($fieldname);
@fieldinfo = $fh->fieldinfo();
Navigation functions
$recno = $fh->recno();
$fh->goto($recno);
$fh->skip($n_recs);
$fh->bof();
$fh->eof();
Record manipulation functions
@values = $fh->fields();
$value = $fh->field($fieldname);
$fh->set_field($fieldname, $value);
$fh->new_record(@values);
$fh->replace_record(@values);
$fh->deleted();
$fh->delete_record($recno);
$fh->flush($tries);
$fh->pack($compress_memo);
$fh->lock($what, $tries);
$fh->unlock();
Index manipulation functions
$n_tags = $fh->tag_count();
@tags = $fh->tags();
@taginfo = $fh->taginfo($index_name);
$fh->open_index($name);
$fh->create_index($name, $taginfo);
$fh->reindex();
$fh->set_tag();
$fh->seek($key);
$fh->scan($pattern, $subr, @args);
Miscellaneous functions
CodeBase::option(@options);
$errno = CodeBase::errno();
$errmsg = CodeBase::errmsg($errno);
$version = CodeBase::libversion;
$dbtype = CodeBase::dbtype;
DESCRIPTIONEach function provided by the CodeBase module is described below. The module uses the CodeBase library from Sequiter Software Inc., which is a C library providing database management functions for dBASE files.
File manipulation functionsExisting dBASE files can be opened with open() and new files created with create(). Files are implicit closed by the DESTROY method, which is called when all references to the internal file handle go out of scope.
Navigation functions
Record handling functions
Index Handling Functions
A production index file is automatically opened when a database file is
opened, if it exists unless the
Miscellaneous functions
ERRORS
Functions return a value on success and
A number of variables are defined as symbolic names for the CodeBase error
codes. Thes variables are all defined in the CodeBase
package and so need to be referred with the package prefix (e.g. General disk access errors
$e4close = -10; # Closing file
$e4create = -20; # Creating file
$e4len = -30; # Determining file length
$e4len_set = -40; # Setting file length
$e4lock = -50; # Locking file
$e4open = -60; # Opening file
$e4read = -70; # Reading file
$e4remove = -80; # Removing file
$e4rename = -90; # Renaming file
$e4seek = -100; # Seeking to a file position
$e4unlock = -110; # Unlocking file
$e4write = -120; # Writing to file
Data file specific errors
$e4data = -200; # File is not a data file
$e4field_name = -210; # Unrecognized field name
$e4field_type = -220; # Unrecognized field type
$e4record_len = -230; # Record length too large
Index file specific errors
$e4entry = -300; # Tag entry missing
$e4index = -310; # Not a correct index file
$e4tag_name = -330; # Tag name not found
$e4unique = -340; # Unique key error
Expression evaluation errors
$e4comma_expected = -400; # Comma or bracket expected
$e4complete = -410; # Expression not complete
$e4data_name = -420; # Data file name not located
$e4length_err = -422; # IIF() needs parameters of same length
$e4not_constant = -425; # SUBSTR() and STR() need constant parameters
$e4num_params = -430; # Number of parameters is wrong
$e4overflow = -440; # Overflow while evaluating expression
$e4right_missing = -450; # Right bracket missing
$e4type_sub = -460; # Sub-expression type is wrong
$e4unrec_function = -470; # Unrecognized function
$e4unrec_operator = -480; # Unrecognized operator
$e4unrec_value = -490; # Unrecognized value
$e4unterminated = -500; # Unterminated string
Optimization errors
$e4opt = -610; # Optimization error
$e4opt_suspend = -620; # Optimization removal error
$e4opt_flush = -630; # Optimization file flushing failure
Relation errors (not used)
$e4relate = -710; # Relation error
$e4lookup_err = -720; # Matching slave record not located
Severe errors
$e4info = -910; # Unexpected information
$e4memory = -920; # Out of memory
$e4parm = -930; # Unexpected parameter
$e4result = -950; # Unexpected result
For detailed explanations of these codes refer to the CodeBase Reference Guide by Sequiter Software Inc.
RESTRICTIONSTags cannot be added to existing index files -- the entire index file must be recreated. This is a restriction imposed by CodeBase 5.1.
FUTURE DIRECTIONSRecord fields may be made into an associative array allowing their values to be accessed and set with the following syntax:
$val = $file->{"F1"};
# rather than: $val = $file->value("F1");
$file->{"F1"} = $newval;
# rather than: $file->set_value("F1", $newval);
COMPATIBILTY
CodeBase Functions
CodeBase 6.4 CodeBase 5.1 CodeBase.pm ============ ============ ===========
code4calcCreate expr4calc_create code4calcReset expr4calc_reset code4close d4close_all implicit on exit code4connect code4data d4data code4dateFormat code4dateFormatSet code4exit e4exit code4flush d4flush_files code4indexExtension code4init d4init code4initUndo d4init_undo code4lock code4lockClear code4lockFileName code4lockItem code4lockNetworkId code4lockUserId code4logCreate code4logFileName code4logOpen code4logOpenOff code4optAll code4optStart d4opt_start code4optSuspend d4opt_suspend code4timeout code4timeoutSet code4tranCommit code4tranRollback code4tranStart code4tranStatus code4unlock d4unlock_files code4unlockAuto code4unlockAutoSet
Data File Functions
CodeBase 6.4 CodeBase 5.1 CodeBase.pm ============ ============ ===========
d4alias d4alias
d4aliasSet d4alias_set
d4append
d4appendBlank d4append_blank
d4appendStart d4append_start
d4blank
d4bottom
d4changed
d4check
d4close d4close undef $fh
d4create
d4delete
d4deleted
d4eof
d4field
d4fieldInfo d4field_info
d4fieldJ d4field_j
d4fieldNumber d4field_number
d4fileName
d4flush d4flush $fh->flush
d4flushData d4flush_data
d4freeBlocks d4free_blocks
d4go d4go $fh->go
d4goBof d4go_bof
d4goData d4go_data
d4goEof d4go_eof
d4index
d4lock
d4lockAdd
d4lockAddAll
d4lockAddAppend
d4lockAddFile
d4lockAll d4lock_all
d4lockAppend d4lock_append
d4lockFile d4lock_file $fh->lock('FILE')
d4lockIndex d4lock_index
d4lockTest d4lock_test
d4lockTestAppend d4lock_test_append
d4lockTestFile d4lock_test_file
d4log
d4logStatus
d4memoCompress d4memo_compress
d4numFields d4num_fields $fh->fldcount
d4open d4open $fh = CodeBase::open($file ...)
d4openClone
d4optimize
d4optimizeWrite d4optimize_write
d4pack d4pack
d4packData d4pack_data
d4position d4position
d4positionSet d4position_set
d4recall d4recall
d4recCount d4reccount
d4recNo d4recno $fh->recno
d4record
d4recPosition d4record_position
d4recWidth d4record_width $fh->recsize
d4refresh d4refresh $fh->refresh
d4refreshRecord d4refresh_record
d4reindex d4reindex
d4remove
d4seek d4seek $fh->seek
d4seekDouble d4seek_double
d4seekN d4seek_n
d4seekNext
d4seekNextDouble
d4seekNextN
d4skip d4skip $fh->skip
d4tag d4tag
d4tagDefault d4tag_default
d4tagNext d4tag_next
d4tagPrev d4tag_prev
d4tagSelect d4tag_select
d4tagSelected d4tag_selected
d4tagSync
d4top d4top
d4unlock d4unlock
d4write d4write
d4writeData d4write_data
d4writeKeys d4write_keys
d4zapData d4zap_data
Date Functions
date4formatMdx date4format_mdx date4formatMdx2 date4format_mdx2 date4timeNow date4time_now
dfile4updateHeader d4update_header e4exitTest e4exit_test error4code e4code error4set e4set
expr4calcDelete expr4calc_delete expr4calcLookup expr4calc_lookup expr4calcMassage expr4calc_massage expr4calcModify expr4calc_modify expr4calcNameChange expr4calc_name_change expr4keyConvert expr4key_convert expr4keyLen expr4key_len
Field Functions
f4assignChar f4assign_char $fh->field_set($name, $value) f4assignDouble f4assign_double f4assignField f4assign_field f4assignInt f4assign_int f4assignLong f4assign_long f4assignN f4assign_n f4assignPtr f4assign_ptr f4memoAssign f4memo_assign f4memoAssignN f4memo_assign_n f4memoFree f4memo_free f4memoLen f4memo_len f4memoNcpy f4memo_ncpy f4memoPtr f4memo_ptr f4memoSetLen f4memo_set_len f4memoStr f4memo_str
file4lenSet file4len_set file4lockHook file4lock_hook file4optimizeWrite file4optimize_write file4readAll file4read_all file4readError file4read_error file4seqRead file4seq_read file4seqReadAll file4seq_read_all file4seqReadInit file4seq_read_init file4seqWrite file4seq_write file4seqWriteFlush file4seq_write_flush file4seqWriteInit file4seq_write_init file4seqWriteRepeat file4seq_write_repeat
i4tagAdd i4add_tag i4tagInfo i4tag_info
relate4createSlave relate4create_slave relate4doAll relate4do relate4doOne relate4do_one relate4errorAction relate4error_action relate4freeRelate relate4free_relate relate4matchLen relate4match_len relate4querySet relate4query_set relate4skipEnable relate4skip_enable relate4sortSet relate4sort_set
t4addCalc t4add_calc t4uniqueSet t4unique_set
tfile4add t4add(a)->tagFile, b, c tfile4block t4block(a)->tagFile tfile4bottom t4bottom( (a)->tagFile tfile4down t4down( (a)->tagFile tfile4dskip t4dskip(a)->tagFile, b tfile4dump t4dump(a)->tagFile, b, c tfile4eof t4eof(a)->tagFile tfile4flush t4flush(a)->tagFile tfile4freeAll t4free_all(a)->tagFile tfile4go t4go(a)->tagFile, b, c, 0 tfile4isDescending t4is_descending(a)->tagFile tfile4key t4key(a)->tagFile tfile4position t4position(a)->tagFile tfile4positionSet t4position_set(a)->tagFile, b tfile4recNo t4recno(a)->tagFile tfile4remove t4remove(a)->tagFile, b, c tfile4removeCalc t4remove_calc(a)->tagFile, b tfile4seek t4seek(a)->tagFile, b, c tfile4skip t4skip(a)->tagFile, b tfile4top t4top(a)->tagFile tfile4up t4up(a)->tagFile tfile4upToRoot t4up_to_root(a)->tagFile
Unsupported functionsMany lower level functions are not directly accessible from CodeBase.pm. These include:
COPYRIGHT AND TRADEMARKSThe CodeBase module is Copyright (C) 1996-1999, Andrew Ford and Ford & Mason Ltd. All rights reserved. The CodeBase library is copyright Sequiter Software, Inc. CodeBase is a trademark of Sequiter Software, Inc.
AUTHORAndrew Ford ([email protected])
SEE ALSOThe Perl reference manual, especially the following sections: perlmod (modules), perldata (data types), perlobj (objects), perlref (references and nested data structures), perldsc (data structures cookbook), perllol (manipulating lists of lists). The second edition of Programming Perl by Larry Wall and Randal L. Schwarz (O'Reilly and Associates) is due to be published late 1996 and covers Perl 5. The CodeBase Reference Guide and the CodeBase User Guide, both from Sequiter Software Inc. cover the underlying C library. |
||||||
Copyright © 1996-2002 Ford & Mason Ltd |