[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nsbasic-palm
Subject:    Re: [nsbasic-palm] Weirdness with dbPut  commands?
From:       Douglas Handy <dhandy1 () bellsouth ! net>
Date:       2002-03-29 15:17:20
Message-ID: gc09aukq48pe056l8ggb29s2j80bvfqif5 () 4ax ! com
[Download RAW message or body]

Avizulis,

>I've noticed a strange behavior with dbPut statements and would like 
>to know whether this is a bug in NSBasic - or whether I'm just not 
>understanding something.

Although I've used DbPosition and DbGet extensively, I've not had a need for
DbPut.  So take this message with a grain of salt.

>Can anyone shed some light on this for me?  Is it a confirmed 
>inconsistency with NSBasic?  

A long time ago, I remember a forum thread where it was mentioned that NSB
evidently adds an extraneous null after the end of the list of variables which
it writes.  This would seem consistent with the results you're experiencing.

I do not know if this only occurs when the final variable in the list is a
string, or if it occurs in all circumstances.

>Should I always assume 2 null terminators when contructing a database?  
>But then, I would need pairs of dbGets to sequentially retrieve data ...

I guess it depends on how you are writing the database, and more especially, how
you are *rewriting* portions of an existing record.  Since strings are variable
length, you need to make sure you don't write a longer string where a shorter
string had been (or you'll corrupt the data which follows).

If each variable is added with a separate DbPut, than you maybe should increment
your offset counter to account for the appraent extraneous null.

In terms of DbGets, you don't really need pairs of them.  Just use:

   Dim strValue as String
   Dim bytNull as Byte

    result = DbGet( db, strValue, bytNull )

and ignore the contents of bytNull.

I have no idea why NSB adds the extra null -- Palm OS does *not* need a record
terminator.  Record lengths are implictly derived by how the OS stores a db's
"recordset" header.

Doug

Community email addresses:
 Post message: nsbasic-palm@yahoogroups.com 
 Subscribe:  nsbasic-palm-subscribe@yahoogroups.com 
 Unsubscribe:  nsbasic-palm-unsubscribe@yahoogroups.com  
 List owner:  nsbasic-palm-owner@yahoogroups.com 

Shortcut URL to this page:
 http://groups.yahoo.com/group/nsbasic-palm  

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic