A89: Re: A Address book With Some Real Problems


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

A89: Re: A Address book With Some Real Problems




Oh boy, this is gonna be fun.  It's 5:30 AM and I can't resist:

> ok, i am trying to get a address book written in c for the calc,

Really?  Strange, judging by that source I would have thought you've written
a LISP interpreter.  How would I have ever known that this is C source
without that helpful little bit?

> but my
> main problem right now is that i can not get the request dialogs working
> right, what am i doing wrong?

Among other things, you are doing all of the following wrong:

(1) Sending five messages to this list within one hour, four of which are
one-liners, two of which are completely incoherent ("muti [sic] request
dialogs in one dialog"?), and all of which have an relatively long 7-line
signature which is really killing your signal-to-noise ratio.

(2) Your spelling and grammar are being "done wrong," thus also implicating
your proofreading of the same felonies.  Out of the four aforementioned
one-lined messages, all four lack any capitalization at all, there are four
spelling errors (two of which are present in two messages, and one of which
is in a subject line), and this message I am replying to lacks any
consistent capitalization scheme (both in the subject and body), and I won't
even comment on your poor selection of "a" as the article preceeding a
subject that begins with the same vowel.

I won't harp on the content of the messages refering to hooking the on
button, since they at least made a little sense if you thought about them a
bit.  But no, int 6 is not run when pressing the on button to turn on the
calc, IIRC.

And if the originator of that thread is still reading this, it IS possible
to hook into turning the calc on via replacing the event manager, although
due to a glaring mistake in the TI-GCC documentation, you're not gonna be
able to figure out how to do it yourself (Zeljko: one of your event
descriptions is completely wrong, giving you two events with similar
effects, one of which is completely wrong.  But you're probably not even
going to find it with that hint).  I'm sorry, but I just can't reveal
anymore.  But it's nice to see that Zeljko is human =)

To Zeljko again: actually, several of those are wrong.  But some are
"wronger" than others =)

Now, onto the code:

(3) There are no function prototypes in this code.  I've seen some 4 new C
programmers in the last week, none of whom use prototypes!  I don't know
who's writing your C tutorials these days, but they're either completely and
utterly incompetent themselves, or having a good laugh at newbies writing
sloppy excuses for code.  Go research and use function prototyping, and use
names in your prototypes - not just types.  This prevents many errors, both
from human mistakes which are not detected by "double-checking" and when the
compiler is forced to make an assumption about the types of the values that
it is pushing onto the stack when calling.

Will more experienced C coders please back me up on the importance of
prototypes?  It seems certain new programmers who I've told to use
prototypes grumpily added them, but don't believe me when I state their
importance.

(4) > char  static FName [100] [15]={{0}};

The static modifier should occur before the type (char), not after.  This is
a fundamental of the C syntax and no code doing it as you are will ever
compile.  Please do not send messages to this list with invalid code - make
an effort to correct some of these innumerable errors before asking for
help, especially ones that will be picked up by the compiler (syntax errors
rather than logic errors) - you should not have nearly this much code when
it likely never even compiled on the first build.

(5) Most of your variables do not need to be globals.  In fact, not only is
it not necessary, but it's not even helpful - IMHO, it's a waste.  All of
the b* variables, for instance, should be defined at the start of the editen
function - not with the globals.

(6) > strncat (buffer, b1, 15);

Since buffer is a null byte, and we're merely appending onto the end of it,
the string will still not be read beyond the first (null) byte.  In other
words, attempting to display the resulting string will display nothing.

(7) > DialogAddRequest (handle, 3, 13, "First Name:",   6, 15, 10);

"Magic numbers" - that is, hardcoded constants - are bad.  Try to replace
some of these numbers with symbolic constants; that is, #define'd values,
like the occurance of "CENTER" in the call to DialogDo.

(8) > return 0;

Why are all of your functions returning unused values?!?  Only your main
needs to be declared as an int here; the rest of your functions should be
declared as returning void.  Once again, learn your fundamental C before
asking for help.

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

Were you to fix up your syntax errors so that the code will actually run,
you'd see that result will never be see to either of those values when
encountering this pretest, and thus the loop is infinite.

> Also, how can i disable the help messages when i call a dialog, ie i want
> to disp my own instead of the use the arrow keys and enter or esc stuff.
> Any help would be welcomed.

Use a callback routine.  I'm not sure how much of that has been documented,
so I'll leave that to Zelkjo to answer if he so chooses in order to avoid
saying anything I shouldn't.  But you shouldn't even be THINKING about doing
this yet.

> Stupidity got us into this mess - why can't it get us out?

A fitting quote, might I add (and one of my favorites =)

Pat, Scott, Zeljko, et al: Go ahead, shoot me down.  I dare ya.  Fix any
glaring oversights and misinformation, and feel free to be as rude and frank
about it as you desire.  It's the best way to learn =)

    -Scott




Follow-Ups: