Thanks. That makes sense. The pointer then goes to the note instead of the description. ----- Original Message ----- From: "Ben Combee" <[EMAIL PROTECTED]> To: "Palm Developer Forum" <[email protected]> Sent: Friday, October 21, 2005 10:43 AM Subject: Re: Accessing Database Records
> At 09:57 AM 10/21/2005, you wrote: > >I am seeking to develop a database application. I have borrowed code from > >two sources that permit such use and spliced it together. I just got to > >the point of creating a database record, accessing one element of it, and > >displaying it. This is where my question comes in. In the one source, it > >uses the following code to access the database record element: > > > >Char* note; > >... > >... > >... > >note = rec->descriptionAndNote + StrLen(rec->descriptionAndNote) + 1; > >FrmCustomAlert(MyAlert, note, NULL, NULL); > > > >I tried to use the middle line in my code to display an element of a > >record. What displayed in my field was "U:", not the content of the field > >that I wanted. I changed the line to read: > > > >note = rec->descriptionAndNote; > > > >When I passed that to my field, the proper element from the record > >displayed. I am wondering why a text that is in its second printing was > >defining the variable "note" using not only an element from a record, but > >the length of the element from the record plus one. > > In this code, two items are being stored in one record. There's first a > NUL-delimited "description", immediately followed by a NUL-delimited > "note". This code is finding the note by going to the end of the > description and then skipping over the NUL terminator, producing a > character pointer into the middle of the database record, but to the start > of the second string. > > > -- Ben Combee, Senior Software Engineer, Palm, Inc. > "Combee on Palm OS" weblog: http://palmos.combee.net/ > Developer Forum Archives: http://news.palmos.com/read/all_forums/ > > > -- > For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ > -- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
