On Thu, Apr 03, 2003 at 01:14:54PM -0500, Dave Lippincott wrote:
> I wouldn't work with the field attributes directly.  This will not work with
> OS 5 or newer versions.  Try running this code in Pose and see how many
> complaints you get.

Er, none? :-)  Or probably one, but for a different reason (below).
This has come up here several times before; see for example

        http://www.escribe.com/computing/pcpqa/m48109.html

> "Jeff" <[EMAIL PROTECTED]> wrote:
>> {
>>   Boolean temp;
>>   FieldAttrPtr ptrFieldAttr;
>>
>>   temp = editable;            // for debug
>>   if(row < TABLEROWS)
>>   {
>>      FldGetAttributes(fld, ptrFieldAttr);
>>      ptrFieldAttr->editable = 0;
>>      ptrFieldAttr->underlined = noUnderline;
>>      FldSetAttributes(fld, ptrFieldAttr);
[...]

Of course, you do have the standard C newbie problem of "it wants a
pointer, so I just gave it a pointer, whaddayamean I'm supposed to give
it the address of some actual writable memory?".

Hint: m68k-palmos-gcc -O -Wall on this code gives you

    warning: `ptrFieldAttr' might be used uninitialized in this function

It'd probably help if the documentation for functions like
FldGetAttributes() were more explicit, saying something along the lines
of
        <- attrP    Address of a variable of type FieldAttrType
                    into which the result is to be written

but basically you're supposed to Just Know.  And in fact this is not an
unreasonable expectation.  A useful habit to get into is:  whenever you
pass a pointer (to a function), *think about* who owns the memory pointed
to, who is going to write to it and read from it, who was responsible for
allocating it, and whether that ownership is transferred by the function
call.

    John  "what Neil said :-)"

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

Reply via email to