On Thu, 13 May 1999, Dave Lippincott wrote:

> My code does work for the second character entered but not the first.  Any
> ideas?
> 
> Here's a little part of the code:
> OurField = (FieldPtr) GetObjectPtr(MyField);
> if(OurField->attr.dirty == 1)
>     {
>     // Do something
>     // This code only gets executed on the 2nd char entered in the field
>     }

Two comments, both unlikely to be helpful for you: if it's happening the
second time, but not the first, check to make sure the event flow actually
matches what you are expecting. Perhaps when the code executes the first
time, the dirty flag really hasn't been set yet. (If the debugger is
giving conflicting information, a more severe problem seems likely.)

Secondly, in C you might want to avoid the "== 1" or "== true" test, and
instead rely on conditional testing. Remember that C accepts any non-zero
value as true, so you can say:

        if (FldDirty(OurField)) // instead of (FldDirty(OurField)==1)

You can test for false by saying "== 0", or by prepending the ! operator.

IMO, this syntax can be preferable as it will accept any non-zero value as
true, and will therefore be more reliable if functions (or the
compiler...) ever returns a value other then 1 to mean true.

-- 
Kenneth Albanowski ([EMAIL PROTECTED], CIS: 70705,126)


Reply via email to