Re: A89: Re: A Address book With Some Real Problems


[Prev][Next][Index][Thread]

Re: A89: Re: A Address book With Some Real Problems




> >(5) Most of your variables do not need to be globals.
> one of the things that one will learn from this is that this is just
> getting it working, and i believe that if you want to use globals, you
can,

Fair enough - getting something functional is always good.

> at this point, how do you know that i will not use them later in the code
> in a different function?

I think that it was a fair inference to make that those were all intended to
be temporary storage, judging by the code that you had completed so far.

> >(7) "Magic numbers" - that is, hardcoded constants - are bad.
> why?

I'd say it's just advice from my personal experience, but even Kernighan and
Ritchie's _The C Programming Languge, Second Edition_ says to use symbolic
constants instead (page 14, for anyone who might want to look that up).
That's the definative C book, written by the designers of the language.

While there's nothing technically "wrong" with it, it's considered bad
practice because it makes code much less readable and more prone to errors.
See my reply to Zeljko for an example of what I use instead.

> >(8) > return 0;
> why not? i believe that it is a style thing, makes all functions look
> neater , unless you can give me a reason why it is bad to do, i will keep
> doing it

Because C wasn't written to be aesthetic, it was written to be efficient.
If you want to be aesthetic, you can go learn Pascal; in fact, I think that
there's even a Pascal compiler for the 89/92+ at http://mxm.ticalc.org/.

Returning a value when one is not necessary will make a program both larger
and smaller, as well as harder to understand for outsiders reading your
source (how are we to knew when these values are actually USED?)

> >(9) > while(result!=0&&result!=9)

I missed the assignment on the popup call.  My fault

> why not? and what is this callback function?

It's fully documented in TI-GCC, and Zeljko provided an example for you in
his code.  To make a long story short, a callback function is called by TIOS
every time a user does something within a dialog box.  It allows you to hook
into the dialog and make changes to it based upon the user's actions,
although all you want it to do is run ST_helpMsg the first time it is called
(which is right after TIOS resets the status line)

    -Scott