![]() |
Home | Java | Palm OS | ASP COM | XML XSL | PHP | Personal | Your IP: 38.103.63.18 |
|
Palm Tutorial: Palm Links: |
What did I understand? First of all let me explain the concept (as I understand it, please correct me if I am wrong) of storing a single text record in the Palm OS. Basically a record in Palm OS is a container to store one large text string. The Data Manager takes care of locking, releasing and deleting a record. What you have to do is fill in your text data in this record. Strings Now if you had one text field in your form it would be okay to store the entire string as one record. But what if your form had two or more text fields? In such a scenario, you would have to keep two separate strings in one big string. For this you must store a collection of small strings which are null ('\0') terminated. Now, if you had two fields with the following sample text data: Text Field 1:
Text Field 2:
Then to store them as one string, the final or packed string would look like this in the record :
So we must device a scheme to 'pack' two or more loose or unpacked strings into one big string. Notice the null terminator '\0'. This is really helpful in our data retrieval routine to read a string upto a null terminator and populate a single element of the structure. And then read the next string till you get another null terminator and so on. Structures To store and handle individual strings from different text fields you must have a structure with elements for every field on your form. This way, it will be easy to assign the text entered by the users to each structure element and handle these structures. It means that you must have two structures - one to store all the 'unpacked' text strings as separate elements and a temporary second one to store all these unapcked strings as one 'packed' string. One more thing: We will decide at the onset about the maximum number of characters that a text field can hold. I have taken an arbitrary figure of 50 characters maximum. We need to do this so that our static structure will always have a fixed size in memory. Though dynamic memory allocation is possible, I decided against it and instead traded off by limiting my text fields to a certain length. Also, this structure is temporary. In the final record we will not be wasting any space as we will pack the strings one after the other. GUI You may already know this but, anyway, here goes... Our multi field form application will have the following general design:
Maybe, my explanation is not very clear, but my source code is commented quite exhaustively. You can definitely find what I missed here in the source code. |
| Home | Java | Palm OS | ASP COM | XML XSL | PHP | Personal | Contact |