From: "Barry Jaques" <[EMAIL PROTECTED]>
> Please excuse my ignorance but I am just learning to use
> CodeWarrior for Palm and having all sorts of difficulties in
> using C with Palm.
>
It seems to me that your problems aren't with Palm OS, but with
C. If you were programming for Windows or Linux in C you'd
be having similar problems.
> is code should work but it doesn't.
> id PutTextForDay(FormPtr frmP) {
> UInt16 attr;
> MemHandle recH;
> FieldPtr fld;
>
> fld = FrmGetObjectPtr (frmP, FrmGetObjectIndex (frmP, ViewErrandField));
> DmRecordInfo (kDBName, CurrentRecord, &attr, NULL, NULL);
> /*MemHandle*/ recH = DmQueryRecord(kDBName, CurrentRecord);
> ErrFatalDisplayIf ((! recH), "Bad record");
It's difficult to say much about this code because it's only a fragment.
CurrentRecord isn't declared or assigned a value so it's difficult to
say whether it's valid or not. Certainly DmQueryRecord(kDBName
is likely to give you trouble because the function is documented as
DmOpenRef dbP, Int16 index and you seem to be passing it the
database name. Have you even opened the database? How are you
ensuring that CurrentRecord is a valid record index?
> So my question is this:
> Is:- MemHandle recH;
> recH = DmQueryRecord(kDBName, CurrentRecord);
> the same as:-
> MemHandle recH = DmQueryRecord(kDBName, CurrentRecord);
>
This isn't a Palm OS issue - it's a C question and it shows that
your problem is your knowledge of C. This is going to continue
to make working with Palm OS frustrating for you and my advice
is that you either take a C training course of some sort or swap
to another language.
The answer is that MemHandle recH; defines a variable and
recH = DmQueryRecord assigns a value to it. MemHandle
recH = DmQueryRecord fails because you're trying to embed
a variable declaration within the body of your code and variable
declarations are only allowed at the top of a block. That's the
reason the first works and the second fails. It's got to do with
the position of the definition, not how it's assigned.
> The Palm OS Reference is extremely cryptic and the samples are sparse.
>
I've worked on a lot of platforms and Palm OS is the best
documented with significant work put into delivering working
samples and a solid support network. C is a tough language
to code in and things aren't just going to fall into place for
you if you're learning C and Palm OS coding at the same
time.
Chris Tutty
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/