>This is not such a good idea because StrAToI doesn't like NULL pointers,
>and if the user has never entered something into the field, then it will
>complain.
It actually does fine thus far. But, I see where the concern is. Good
practice
would be to get the Ptr, check for NULL, and then assign it, correct?

>It's also completely illegal. What good is converting an integer into a
>pointer going to do you?
Well, although completely illegal it works. Why would CodeWarrior allow
me to perform such a haneous action if it was that bad.

I'm asking not to be argumentative as I really do appreciate you
responding,
I'm just curious as a new programmer why something this simple could slip
through?

I've been meaning to get a better understanding of pointers, I'm kinda
running & gunning
it, learning as I go... which I know would make some programmers cringe,
especially
on such a particular device in terms of memory. If you have a book in mind,
that explains
pointers extremely well, I'd love to hear it.

Thanks Dave.

Nole Mailey




|---------+------------------------------------------->
|         |           Dave Carrigan <[EMAIL PROTECTED]>|
|         |           Sent by:                        |
|         |           [EMAIL PROTECTED]|
|         |           .palmos.com                     |
|         |                                           |
|         |                                           |
|         |           08/13/2003 06:54 PM             |
|         |           Please respond to "Palm         |
|         |           Developer Forum"                |
|         |                                           |
|---------+------------------------------------------->
  
>------------------------------------------------------------------------------------------------|
  |                                                                                    
            |
  |        To:      "Palm Developer Forum" <[EMAIL PROTECTED]>                        |
  |        cc:      (bcc: Nole Mailey/pmc)                                             
            |
  |        Subject: Re: "Low Memory" - (Newbie Ques)                                   
            |
  
>------------------------------------------------------------------------------------------------|




On Wed, Aug 13, 2003 at 06:41:19PM -0500, [EMAIL PROTECTED] wrote:

> Okay, this a bit of a dorky question. I asked at a C Forum, and this
> was the suggestion. I'm hoping this is a Palm Dev Forum related issue:

It is a C issue, although the error message you get is a bit nicer than
the error message you might get from another OS.

>       typedef struct
>       {
>             UInt32 *orderQty;
>             Char *key;
>             Char *desc;
>       } OnOrder;
>
>       onOrder.orderQty = (UInt32 *) StrAToI(FldGetTextPtr(field));
// Gets the number from the field

This is not such a good idea because StrAToI doesn't like NULL pointers,
and if the user has never entered something into the field, then it will
complain.

It's also completely illegal. What good is converting an integer into a
pointer going to do you?

>       UnpackOnOrder(&onOrderFound, packedOnOrder);          // Grabs from
> pdb
>       *(onOrder.orderQty) += *(onOrderFound.orderQty);            // THIS
LINE CAUSES THE ERROR

Well, since you did that bizarre assignment earlier, the value of
orderQty is whatever value was in the form. My guess is that it was 20,
since your error message was "Application just read from memory location
0x0000000014", and 0x14 == 20.

You should get a good book on C and programming with C pointers. If the
people on the C forum had read your code more carefully, they would have
seen the problem as well.

--
Dave Carrigan
Seattle, WA, USA
[EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL

Dave is currently listening to Crosby, Stills, Nash & Young - This Old
House (American Dream)

--
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