#!/usr/bin/perl -w

use strict;
use XBase;

my $table = new XBase "ndx-num.dbf";
my $cur = $table->prepare_select_with_index("ndx-num.ndx");
$cur->find_eq(1097);

while (my @data = $cur->fetch())
	{ print "@data\n"; }


__END__

In the 0.063 version of XBase module, there is a new support for ndx
index files. I'm trying to find the best interface to that, so
anything described here can change.

Note that similar syntax works even without index, the current
versions of XBase.pm support

	my $table = new XBase "ndx-num.dbf";
	my $cur = $table->prepare_select();

	while (my @data = $cur->fetch()) 
		{ print "@data\n"; }

which looks pretty similar and it is indead. Only, you cannot do that
find_eq. If you use prepare_select_with_index, you can call fetch
dirrectly without find_eq, then you will get all value in the order
given in the index, as in the example below.

__END__

#!/usr/bin/perl -w

use strict;
use XBase;

my $table = new XBase "orders";
my $cur = $table->prepare_select_with_index("klantnum.ndx",
	qw( ORDER_ID KLANTNUMME WERKNEMER_ VERVALDATU LEVERDATUM));

while (my @data = $cur->fetch())
	{ print "@data\n"; }

__END__

Currently supported are character and numeric indexes, those numeric
only tested on Linux/i586 (little-endian) so far.

If you want to test if the XBase::Index part wors fine on your data,
you can call it directly:

#!/usr/bin/perl -w 

use strict;
use XBase::Index;

my $index = new XBase::Index "klantnum.ndx";
$index->prepare_select;

while (my @data = $index->fetch())
	{ print "@data\n"; }

__END__

This will list the keys from the ndx file, together with their
corresponding values, which are the record numbers in the dbf file.
If the results are not those you would expect, email me (module date
type which doesn't work yet).

If you want to help even more, you can use

	print Dumper $index;

or something similar to se what's going on in the module. And of
course, there is the source to check and decrypt ;-)

The name XBase::Index is not very meaningfull, especially as we will
hopefully support wider variety of index types. It will change, so do
not depend on it. Anyway, the sooner we find the first 50 per cent of
the bugs and agree on the interface, the sooner you can start writing
scripts that won't need to be changed with each new version of
XBase.pm.


