Thank you for the reply. The fog is lifting!!!

  The path I was tripping on was.

     User taps into a filed col. Then they type tap another field col.

     In your explanation. the Save callback will clean it up. Then the load
     will be called as a re-draw is needed and the handle re-allocated.

  I will write a sample app later today.

  Again Thanks and to all a good weekend!

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Dave
Lasker
Sent: Friday, May 07, 2004 1:00 PM
To: Palm Developer Forum
Subject: Re: Looking for a simple sample of using textTableItem and
custom Loa d and Save procedures


The table mechanism was originally designed to meet the needs of the
built-in applications, where the textTableItem handles point to persistant
database fields. In this case, you don't want to free the field. For a good
example of this type of usage, see the built in Address application (source
code included with SDK), file AddrEdit.c.

If you are using a table to manage non-persistant data, then you need to
keep track of memory allocation yourself. Any memory allocated in your
TblSetLoadDataProcedure that was not freed by your TblSetSaveDataProcedure
must be freed in your processing of your frmCloseEvent.

My application is structured similarly to your code, and I also got the same
kind of crash as you. I believe it was caused by the text field's data being
moved by the OS while text was entered into the field, which invalidated the
data saved in gTextHandles. I fixed this by doing the following:

1) Don't preallocate the gTextHandles. Start with the array zeroed out.

2) In your TblSetLoadDataProcedure, if gTextHandles[row] is zero, call
MemHandleNew to allocate it.

3) In the TblSetSaveDataProcedure, always call FldFreeMemory on the field,
and zero out gTextHandles[row].

4) In the frmCloseEvent, free all non-zero elements of gTextHandles.

HTH...

Dave


"Muriph, Michael " wrote in message news:[EMAIL PROTECTED]
>
>
>     Some basic principles I think I am missing/lacking!!!
>
>     1) When you hand a textTableItem a handle in the Load call back
when/if does
> the
>        field contained in the table free the handle. ( Assuming the Save
> callback is not
>        implemented).
>
>     2) In a TableSaveDataFuncType ( only called if the user tapped and is
> leaving the field)
>        Should you set the Fld Text handle to 0??
>
>     3) As all can see I am no expert!! If I have a table that has 4 rows 2
cols
> each.
>        Col 0 is the lablel col. Col 1 is the col for the user to
edit/create the
> data.
>
>        If I load the table and the user never edits, the save callback
never
> happens.
>        Where does the clean up code go? Is this how must folks use tables
>
>
>     I have the following:
>
> MemHandle gTextHandles[5];   <-- 5 mem handles to set in my custom Load
> callback.
>
>
>
>      In the frmOpenEvent I allocate the handles
>
> char *tempString;
>
> for (I = 0, i<4 , i++)
> {
> gTextHandles[i]= MemHandleNew(20);
> tempString = MemHandleLock(gTextHandles[i]);
> StrCopy(tempString , "Some Text!");
> MemHandleUnlock(gTextHandles[i]);
>
> }
>
>      In the Load call back I assing the pointers to this global mem
handles
>
>      In the frmCloseEvent I want to clean up
>
> for (I = 0, i<4 , i++)
> {
> MemHandleFree(gTextHandles[i]);
> }
>
>       But my app crashes [EMAIL PROTECTED]
>



-- 
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to