[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [coldsync-hackers] p5-palm: problems looping through recordset and fields
Hey Greg,
The technical specification for PDAT PDB's is here:
http://www.pdatnutsandbolts.com/forums/local_links.php?action=links&catid=7
I think that Palm::Raw handles everything up to the actual record
parsing (although this will require some tests). The spec for the
record layout is pretty striaght forward. I'm going to need
exactly the same thing as you, as I am switching some of our apps
to PDAT, so I'll be happy to post code here when I get it working.
Could you post your pdb to the group as well? That way I'll have
a couple of different pdb formats to play with.
on Friday, Apr 09, 2004, Greg Gard, wrote:
> thanks, very helpful. as you've correctly surmised, i am a newbie to perl. i
> do have three more question before i wander through your primer though.
>
> 1.) i found good documenation for pack/unpack in the o'rielly programming
> perl book (duh). i think i now get that it converts back and forth from
> binary to string and that .pdb files are in binary format (please correct me
> if i'm wrong). so if i want to do anything with the data, i have to run it
> through unpack?
>
>
> 2.) what is the correct means of referencing a field once i've parsed it.
>
> for example, below i have:
>
> my $orgkey = $record[ORGK];
>
> i found something similar in the cold-sync archives, but it doesn't seem to
> work. what is the correct syntax?
>
> 3.) are there any significant differences in .pdb structure across palm os
> versions. will this script work on older versions like that shipped with
> PalmIII or Visor Delux.
>
> sorry to ask such newbie stuff, but this is a growing edge for me. thanks
> for all your help...gg
>
>
> -----Original Message-----
> From: owner-coldsync-hackers@lusars.net
> [mailto:owner-coldsync-hackers@lusars.net]On Behalf Of Andrew
> Arensburger
> Sent: Thursday, April 08, 2004 11:30 PM
> To: coldsync-hackers@lusars.net
> Subject: Re: [coldsync-hackers] p5-palm: problems looping through
> recordset and fields
>
>
> On Thu, Apr 08, 2004 at 11:16:39PM -0400, Greg Gard wrote:
> > perl script (what i'd like to do, but doesn't really work):
> >
> > use strict;
> > use Palm::Raw;
> >
> > ...(other misc code)...
> >
> > #LOOP THROUGH RECORDS
> > my $questionid;
> > my $qnum = 0;
> > foreach $rs (@{$pdb->{records}}) {
> > my @record = unpack("a", $rs->{data});
> > my $orgkey = $record[ORGK];
> ^^^^^^
> > my $surveykey = $record[SRVK];
> ^^^^^^
> >
> > #LOOP THROUGH FIELDS
> > foreach $fld (@rs){
> > $qnum++
> > if ($record["Q" . $qnum] != ""){
> ^^^^^^^^^^^^^
> > my $questionid($qnum) = $record["Q" . $qnum];
> ^^^^^^^^^^^^^
> > }
> > }
> > }
>
> You may want to read up on the difference between arrays and
> hashes. Perl isn't PHP.
> http://www.ooblick.com/text/perl/ might prove useful.
>
> > i like unpacking to a single hash as opposed to a statement like:
> >
> > my ($var1, $var2, $var3) = unpack($unpackstr, $rs->{data});
> >
> > because i'd like to just loop through fields testing for null. also, i was
> > unable to find any documentation on how to set $unpackstr (i found this in
> > your mailing list archives). where can i find documentation about how to
> set
> > unpack str.
>
> How about TFM? Specifically, perlfunc(1). Look for "unpack".
>
> --
> Andrew Arensburger This message *does* represent the
> arensb@ooblick.com views of ooblick.com
> Cat rule #2: Bite the hand that won't feed you fast enough.
> This message was sent through the coldsync-hackers mailing list. To remove
> yourself from this mailing list, send a message to majordomo@thedotin.net
> with the words "unsubscribe coldsync-hackers" in the message body. For more
> information on Coldsync, send mail to coldsync-hackers-owner@thedotin.net.
>
>
> This message was sent through the coldsync-hackers mailing list. To remove
> yourself from this mailing list, send a message to majordomo@thedotin.net
> with the words "unsubscribe coldsync-hackers" in the message body. For more
> information on Coldsync, send mail to coldsync-hackers-owner@thedotin.net.
--
Brett Paden
bpaden@trimeros.com
http://trimeros.com
877.352.data (office)
954.663.0678 (cell)
This message was sent through the coldsync-hackers mailing list. To remove
yourself from this mailing list, send a message to majordomo@thedotin.net
with the words "unsubscribe coldsync-hackers" in the message body. For more
information on Coldsync, send mail to coldsync-hackers-owner@thedotin.net.