[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[coldsync-hackers] p5-palm: problems looping through recordset and fields
- To: <coldsync-hackers at lusars dot net>
- Subject: [coldsync-hackers] p5-palm: problems looping through recordset and fields
- From: "Greg Gard" <ggard at carepaths dot com>
- Date: Thu, 8 Apr 2004 23:16:39 -0400
- Importance: Normal
- In-reply-to: <200404090233.i392Xn1W092986@shell.lusars.net>
- Reply-to: coldsync-hackers at lusars dot net
- Sender: owner-coldsync-hackers at lusars dot net
hi all,
i looked through the archives and found some solutions that helped, but i'm
still having problems. i'm using pda toolbox to develop a simple survey for
the palm. so far, all is well, i can get the data in a pdb file on the
desktop. what i need to do now is to parse the pdb file and then build a
http get request to upload it to the web. i have the basics of the uploader
together, but i'm having trouble reliably accessing the records. one other
thing, the pda app has several different surveys with different numbers of
fields so i need to be able to loop through the fields to check whether the
responses have stopped (ie the pda database has 100 columns, but the surveys
have varying numbers less than 100 with the empty columns just returning
null).
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];
}
}
}
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. trial and error suggests that a4 would unpack the record to a
four element array, but i couldn't make this work and would get an error
when i then tried to call $record[fieldname] as the array wants integer
subscripts.
as for the looping through the fields part, i really couldn't get that to
work, but the above is what i'd like. the idea being that it would get the
organization key and survey key and then loop through the question fields
populating the questionid array if the response is not emptystring.
beyond this, i want to delete the records once they've been uploaded from
both the palm and the backup pdb.
any guidance, faqs, or other documentation sources much appreciate. oh, and
by the way, this is really cool stuff...gg
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.