>I assigned the bit backup of one database that I build in my application
>on the PalmV so I can have on my desktop after activating Hotsync. The
>only problem I have is that I can not import that database to Excel.
>How to build a file, a database, or any other data structure in a palm
>application in such a way I can, after Hotsync performance, import into
>excel for statistical calculation?
I use a small Perl-program to convert my PDB-files to Excel spreadsheets. I
include the program below. You can modify it to your own record format by
changing the declaration of the @DATANAMES and $DATAPACK variables (if your
records are not fixed-size structures, you may need to do other
modifications).
// Niklas
----------------------------------------------------------------------
#!/usr/local/bin/perl -w
use strict;
# A perl program that converts a pdb database to an Excel spreadsheet.
# by Niklas Frykholm ([EMAIL PROTECTED])
#
# Note that you must change @DATANAMES and @DATAPACK so that they reflect
# the structure of the records in the database you want to parse. No other
# parts of the program should need to be changed.
my (@HEADNAMES, $HEADPACK, @RECNAMES, $RECPACK, @DATANAMES, $DATAPACK);
# Describes the structure of the records in the database.
#
# NOTE! These variables must be updated to reflect the format of your
# records. The first variable lists the names of your record fields.
# The second variables specifies the type of the fields (in pack-format,
# read the documentation of the pack-function in the perl man pages for a
# description.)
@DATANAMES = qw (markers icons words length gen dist
subject runs p1 p2 p3 p4 p5 p6 p7
sx1 sx2 sx3 sx4 sx5 sx6 sx7
sy1 sy2 sy3 sy4 sy5 sy6 sy7
cx1 cx2 cx3 cx4 cx5 cx6 cx7
cy1 cy2 cy3 cy4 cy5 cy6 cy7
time);
$DATAPACK = "c6A30CC7C7C7C7C7N";
# Describes the structure of the database header
@HEADNAMES = qw(name attr version created modified backuped modnumber
appinfo sortinfo type creator seed dummy nrecords);
$HEADPACK = "A32b16nN6A4A4N2n";
# Describes the structure of the record descriptors
@RECNAMES = qw(offset attr dummy);
$RECPACK = "Nb8a3";
main();
sub main {
my (%headers, $i, %rec, %nextrec, %data, $length, $outname);
# Convert all argument files
for (@ARGV) {
open (FILE, "<$_") || die "open $_: $!";
binmode FILE;
# Open output file
$outname = $_;
$outname =~ s/\..*$/.tab/i;
open (OUT, ">$outname") || die "open $outname: $!";
# Print record headers
for (@DATANAMES) {
print OUT "$_\t";
}
print OUT "\n";
# Read database header
read_structure(*FILE, 0, pack_size($HEADPACK), $HEADPACK,
\@HEADNAMES,
\%headers);
# Read records
for ($i=0; $i<$headers{'nrecords'}; $i++) {
# Read record descriptor
read_structure(*FILE, pack_size($HEADPACK) + $i *
pack_size($RECPACK),
pack_size($RECPACK), $RECPACK, \@RECNAMES, \%rec);
# Determine record length and read record
if ($i+1 < $headers{'nrecords'}) {
read_structure(*FILE, pack_size($HEADPACK) + ($i+1) *
pack_size($RECPACK), pack_size($RECPACK),
$RECPACK,
\@RECNAMES, \%nextrec);
$length = $nextrec{'offset'} - $rec{'offset'};
} else {
$length = 1000000;
}
read_structure(*FILE, $rec{'offset'}, $length, $DATAPACK,
\@DATANAMES,
\%data);
# Output record
for (@DATANAMES) {
print OUT "$data{$_}\t";
}
print OUT "\n";
}
close FILE;
close OUT;
}
}
# read_structure (*FILE, $offset, $length, $pack, \@names, \%table)
#
# Reads the structure with recordnames @names, and record types described
# by $pack from the file FILE. The functions starts reading at $offset and
# reads a total of $length bytes. The structure is stored in %table.
sub read_structure {
local(*FILE) = shift(@_);
my ($offset, $length, $pack, $names, $table) = @_;
my (@F, $i, $data);
%$table = ();
seek(FILE, $offset, 0);
read(FILE, $data, $length);
@F = unpack($pack, $data);
for $i (0..$#F) {
$table->{$names->[$i]} = $F[$i];
}
}
# pack_size($pack)
#
# Returns the number of bytes required by the structure whose type
# is described by the pack-string $pack.
sub pack_size {
my ($pack) = @_;
my($s) = pack($pack, ());
return length($s);
}