Eric,
>Each record will contain one numeric
>field, with anywhere from 0 to many records being written. I examined an
>NSBasic created and populated PDB in a hex editor and, with some help, came
>up with a structure of:
>
>struct{
> UInt32 recordIndex;
> UInt32 IntegerData;
>};
That wouldn't be right if the NSB/Palm database really only contains one numeric
field. NSB/Palm databases are just standard Palm OS databases. The recordIndex
above is not part of the data record unless the program writes a numeric
variable with a counter as the first data field. The above structure has two
fields. In NSB, the data type "Integer" corresponds to Int32 in CW; NSB/Palm
has no data type which is unsigned (so you'd need to use two's complement for
values with the high-order bit set).
>The above structure, when used to write records to the database, seems to
>conform to the format that NSBasic would use in creating a similar database.
Not if you are only writing out one Integer variable within NSB. The above
structure writes two. The "recordIndex" would just be a data field, and has no
direct bearing to the sequence in the database, although the program may well
have populated the values consecutively.
>In the NSBasic application there is a NULL Handle error given on a dbread
>statement. Regarding the dbread statement, I've verified that the database
>is open and that the index of the record being read is valid.
Under Palm OS, a record index is a zero-based number. NSB/Palm uses record
numbers, not record indexes, so the records are one-based not zero based.
Also, DbRead() in NSB/Palm uses the first variable named as a "key" and binary
searches the database to find a record whose contents matches the requested
value. It is not a record number -- it is a variable within the record.
DbInsert() is similar. To access by record number, you'd use DbPosition()
followed by DbGet() or DbPut().
That said, if you're getting a NULL handle error on a DbRead, then you're trying
to access more data than exists in the record. NSB/Palm has no inherent
knowledge of what is in any record. It relies on the list of variables you
request to map the record contents into those variables. It sounds like you are
requesting more data than exists in the record.
>Does anyone have any ideas of why I'm getting that NULL Handle error? I'm
>not very familiar with NSBasic, but have good knowlege of coding in Code
>Warrior.
You'd have to post the NSB/Palm code snippet and CW code snippet for a
definative answer. But I suspect you are using DbInsert() an DbRead() in
NSB/Palm and supplying an Integer which you think is the record index. It's
not. That would be a data field.
If not using DbRead/DbInsert, remember that record numbers for DbPosition are
one-based, while record indexes for DmQueryRecord() are zero based.
Doug
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/