Palm::Datebook problem

Palm::Datebook problem

am 02.09.2007 11:24:57 von pdc124

Im trying to write data to the palm Datebook file ( adn then sync the
new information a bit later)
I create an emptry datebook

use strict;
use Data::Dumper;
use Palm::PDB;
use Palm::Datebook;
my $pdb = new Palm::Datebook;
my $filename='/tmp/palm/DatebookDB.pdb';
$pdb->Write($filename) or die " cant write file"; exit;

which creates a Datebook

paul@skippy /tmp/palm $ ls -ls |grep DatebookDB.pdb
4 -rw-r--r-- 1 paul paul 360 Sep 2 10:05 DatebookDB.pdb

I can then read the records ( and get nothing )
$pdb->Load($filename) or die " cant load file";
my $nums = @{$pdb->{records}};
print "printing records\n---------------------\n";
for ( my $i=0; $i<$nums; $i++ ) {
print "$i : ";
my $record = $pdb->{records}[$i];
print " $record->{year}-$record->{month}-$record->{day}: $record-
>{start_hour} $record->{start_minute} to $record->{end_hour}$record-
>{end_minute} ";
print "$record->{description} ";
print "$record->{note}";print "\n";
}
exit;

I then try and write new record to the file

{
my $newrecord = $pdb->new_Record;
$newrecord->{day}="13";$newrecord->{month}="9";
$newrecord->{year} ="2007";
$newrecord->{description} ="another test entry";
$newrecord->{start_hour}="11"; $newrecord->{start_minute}="10";
$newrecord->{end_hour}="11"; $newrecord->{end_minute}="20";
$newrecord->{note}="testnote";
print Dumper($newrecord);
$pdb->append_Record or die " cant add record";
$pdb->Write("/tmp/palm/DatebookDB.pdb") or die " cant write file";;
}

has this output
paul@skippy /tmp/palm $ ./readdb.pl
printing records
---------------------
$VAR1 = {
'exceptions' => [],
'month' => '9',
'end_minute' => '20',
'description' => 'another test entry',
'start_minute' => '10',
'note' => 'testnote',
'end_hour' => '11',
'day' => '13',
'repeat' => {},
'alarm' => {
'advance' => 10,
'unit' => 0
},
'start_hour' => '11',
'category' => 0,
'id' => 0,
'attributes' => {
'Dirty' => 1,
'dirty' => 1
},
'year' => '2007'
};
paul@skippy /tmp/palm $

the file has changed in size

paul@skippy /tmp/palm $ ls -ls |grep DatebookDB.pdb
4 -rw-r--r-- 1 paul paul 378 Sep 2 10:12 DatebookDB.pdb

and when i try to read this data back i get this

printing records
---------------------
Use of uninitialized value in concatenation (.) or string at ./
readdb.pl line 28.
Use of uninitialized value in string at ./readdb.pl line 29.
0 : 2007-9-2: 255 255 to 255255
paul@skippy /tmp/palm $

ie its added to the file an entry for today (Sep2 ) . Hexdump of
Datebook.pdb has no 13 anywhere that I can find

and when i sync this file with my palm i get nothing on Sep13

anyone tell me where ive gone wrong ?

Re: Palm::Datebook problem

am 02.09.2007 19:05:32 von pdc124

looking in /usr/lib/perl5/site_perl/5.8.8/Palm

its says this so my new record is being created with the default
values .
I wonder why


sub new_Record
{
my $classname = shift;
my $retval = $classname->SUPER::new_Record(@_);

# By default, the new record is an untimed event that occurs
# today.
my @now = localtime(time);

$retval->{day} = $now[3];
$retval->{month} = $now[4] + 1;
$retval->{year} = $now[5] + 1900;

$retval->{start_hour} =
$retval->{start_minute} =
$retval->{end_hour} =
$retval->{end_minute} = 0xff;

# Set the alarm. Defaults to 10 minutes before the event.
$retval->{alarm}{advance} = 10;
$retval->{alarm}{unit} = 0; # Minutes

$retval->{repeat} = {}; # No repeat
$retval->{exceptions} = []; # No exceptions

$retval->{description} = "";
$retval->{note} = undef;

return $retval;
}