14 Jan 2005 23:37:10 UTC
- Distribution: DB-Appgen
- Module version: 1.02
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (2)
- Testers (0 / 13 / 0)
- KwaliteeBus factor: 1
- % Coverage
- License: unknown
- Activity24 month
- Download (10.96KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionAMALTSEV Andrew Maltsev
- FILE LEVEL METHODS
- $db=new DB::Appgen file => 'filename', create => 1, hsize => 0, truncate => 1;
- ag_db_create('filename', 0, 1);
- $db=new DB::Appgen file => 'filename';
- RECORD LEVEL METHODS
- FIELD LEVEL METHODS
- ag_db_stat($db, $attr, $value);
- $db->delete(attribute => $attr, value => $value);
- $db->extract(attribute => $attr, value => $value, size => $size);
- $db->insert(attribute => $attr, value => $value, text => $text);
- $db->replace(attribute => $attr, value => $value, text => $text);
- ag_replace($db, $attr, $value, $text);
- SUPPORTING METHODS
- SEE ALSO
DB::Appgen - Perl interface to APPGEN databases
use DB::Appgen; my $db=new DB::Appgen file => "order.db"; $db->seek(key => 'Test); my $data=$db->record; print "quantity=", $data->->; $db->replace(attribute => '1', value => '2', text => 'Test Data 1-2'); $db->commit; $db->close;
Function oriented (mimics appgen C toolkit):
use DB::Appgen qw(:all); my $db=ag_db_open('sales.db'); ag_db_newrec($db,'Test',0); ag_insert($db,1,2,'Test Data 1-2'); ag_db_write($db); ag_db_close($db);
This is DB::Appgen - low-level functions for APPGEN database manipulations (you probably already know what appgen is if you loaded this module, but if you don't please visit http://appgen.com/ - in short it is the sytem behind these green salesman terminals you see in various ikeas, sears and so on).
All this was made in about ten hours including reading perlxstut and perlpod manpages, so do not expect something pretty. Although it appears to be working OK in my tests.
Whenever possible it is recommended to use object oriented interface to appgen. The list of all methods and their equivalent functions follows.
Closes underlying database handler. Function must be called in order for the database to be in correct state, while for object oriented method it is only a recomendation to call it.
Object would be closed by perl's garbage collector if you forget about it.
Creates new database or truncates existing one.
Deletes the file associated with the database. Be careful!
Opens existing database.
Re-positions current record pointer to the first record in file.
Attempts to find and, if specified, lock the record by given key. Moves current record on success. In case of of error current record is not defined.
Writes changes made to the current record to the database.
Unlocks current record if it is locked; current record becomes undefined.
Finds and locks existing records or creates new one. Size can be set to the total record size in bytes if you know it, otherwise do not supply it at all.
Deletes current record which must be locked.
Moves current record to the next record in the database in random order locking it if required. Returns key text or undef if no more records exist.
This method determines the size and composition of a field in the current record. Consult appgen documentation for details.
A number of methods exists to get the same functionality in more straight forward way:
Returns number of attributes in the current record.
- $db->values_number(attribute => $attr);
Returns number of values in the given attribute of the current record.
- $db->value_length(attribute => $attr, value => $value).
Returns length of the given value in the given attribute of the current record. If value is not set or is zero then length of entire attribute is returned (for multi-valued attributes this includes value separators).
Deletes given value or attribute in its entirety if no value number is given. Attributes or values after deleted one are renumbered to fill the gap, be careful.
Returns the content of the given value or the given attribute if value is zero. Size is not required, by default entire string is returned.
Inserts new field into the current record. If there is already a field at $attr/$value it is renumbered one higher.
Replaces the field pointed to by attribute and value. Any fields between the end of the current record and the specified field will be created if required.
Reads entire attribute returning array of all values even if only one exists. Values are numbered from 0, not form 1, be careful!
Returns array reference or array itself in array context.
Reads entire current record into array of the following structure: [ 'key', [ 'multi', 'valued', 'attribute' ], 'single valued attribute', ... ]
Returns array reference or array itself in array context. Values are numbered from 0, not form 1, be careful!
None by default.
Copyright (c) 2000 XAO Inc., Andrew Maltsev
http://xao.com/, http://sourceforge.net/projects/dbappgen/, http://appgen.com/