package SCSpots; use warnings; use strict; our $VERSION = '0.02'; use base 'Class::DBI'; use Class::DBI::AbstractSearch; use Win32::TieRegistry( Delimiter => '/', ArrayValues => 0, ); my $dxlab = $Registry->{'CUser/Software/VB and VBA Program Settings/'}; my $DXLABDIR = $dxlab->{'DXLabLauncher/Settings//App(23) Path'}; $DXLABDIR =~ s#[/\\]Launcher[/\\].*##; my $sc_reg = $dxlab->{'SpotCollector'}; my $spotdb_regkey = 'Spot/SpotDatabasePathname'; $spotdb_regkey =~ s#.+/#$&/#; our $spotDbFile = $sc_reg->{$spotdb_regkey}; print STDERR "SpotCollector spots database:\n\t$spotDbFile\n"; sub connect { my $self = shift; $self->db_setup(file => $spotDbFile); } sub disconnect { my $self = shift; $self->db_Main->disconnect; } __PACKAGE__->connect(); sub db_setup { my $self = shift; my $p = { @_ }; my $file = $p->{file}; my $dbopts = $p->{dbopts} || { AutoCommit=>0, LongTruncOk => 1, LongReadLen => 255 }; my $dsn = 'driver=Microsoft Access Driver (*.mdb);dbq=' . $file; my $rc; # trap errors, specifically for the case that the mdb doesn't exist eval { $rc = $self->set_db('Main', "dbi:ODBC:$dsn", '', '', $dbopts ); }; warn "ERROR in db_setup('$file'): $@" if $@; return $rc; } __PACKAGE__->sql_transformer_class('Class::DBI::SQL::Transformer::Quotify'); __PACKAGE__->table('Spots'); __PACKAGE__->columns( Primary => 'Index' ); __PACKAGE__->columns( Essential => qw/ Callsign DXCCPrefix DXCCID Source Network Mode Band Notes Index NoteSource Frequency SpotTime FirstTime LastTime DXGrid OriginGrid /); 1;