Dear Faisal,
Sometimes code snippets can be deceiving especially to someone just starting
out learning C. The code snippet you are offering us contains several
problems. I can't tell if what you posted contains typos, or if it the
actual code you are trying to run. It looks like you want to set the title
of a form to "Set # <some number>".
Here is one fairly basic way to do want you are trying to do.
Give your form the title "Set #" in Constructor or PILRC.
Have the following declarations in the globals section of your program:
CharPtr Title = " "; // 10 spaces between the quotes.
CharPtr SetNum = " "; // 3 spaces between the quotes.
// Title has to be big enough to contain the entire title after you have
appended the set number string to "Set #".
// SetNum has to be big enough to hold two number characters plus the
trailing NULL.
// Below is the function that encapsulates the title change. You will pass
it the number that you want to appear in the title, up to two digits.
static void MySetTitle (int Num)
{
FormPtr frm;
frm = FrmGetActiveForm();
StrCopy (Title, FrmGetTitle(frm));
StrIToA (SetNum, Num);
StrCat (Title, SetNum);
FrmSetTitle (frm, Title);
FrmDrawForm(frm);
return;
}
You would call the above with:
MySetTitle (2);
to change the form title to "Set #2".
Here are some beginner hints.
1. Make sure all your variables are declared before you use them. In your
example you need to have "form" declared as FormPtr or FormType* (depending
on which version of the OS you are using) before you attempt to assign a
value to it.
2. It's good practice to have have all your variable declarations at the top
of each function.
3. When you see "parse error before <something>" it usually means you have a
syntax error in the line right before the line containing <something>.
4. Look for missing semicolons at the end of code statements.
5. Make sure your are not using a name reserved by the OS for a variable
name. I don't think "form" is reserved word but it is a good habit to use
"frm" instead of "form".
6. Initialize variables before you use them.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Faisal
Amlani
Sent: Friday, July 28, 2000 8:31 PM
To: Palm Developer Forum
Subject: Re: Integer conversion
I still get the error:
m68k-palmos-coff-gcc -O2 -g -c dotbook.c -o dotbook.o
dotbook.c: In function `InitializeForm':
dotbook.c:118: parse error before `char'
dotbook.c:120: `d' undeclared (first use this function)
dotbook.c:120: (Each undeclared identifier is reported only once
dotbook.c:120: for each function it appears in.)
make: *** [dotbook.o] Error 1
Here is the code that is generating the error:
form = FrmGetActiveForm();
char x[2];
int num;
StrIToA( d, 25 );
if(location==1) {
FrmSetTitle (form, x);
}
FrmDrawForm(form);
It's just a test, and I'm new. what am i doing wrong?
"Nesse, Rustin" <[EMAIL PROTECTED]> wrote in message
news:19152@palm-dev-forum...
>
> You need to make the characters into strings.
> Ex.
> Char d;
> becomes
> Char d[2];
> or something like that, then:
>
> Int a;
>
> StrIToA( d, 25 );
>
> a = StrAToI( d );
>
> The thing is, you need a string for numbers that have more
> than one digit in them. Char d just doesn't cut it.
>
> What you're passing in to StrIToA and StrAToI is a CharPtr,
> or string name.
> -Rus
>
> >-----Original Message-----
> >From: Faisal Amlani [mailto:[EMAIL PROTECTED]]
> >Sent: Friday, July 28, 2000 3:39 PM
> >To: Palm Developer Forum
> >Subject: Re: Integer conversion
> >
> >
> >I keep getting a parse error before "char";
> >"Nesse, Rustin" <[EMAIL PROTECTED]> wrote in message
> >news:19142@palm-dev-forum...
> >>
> >> Well, you could use StrIToA or StrAToI, both diagrammed in
> >> the Reference. You'll want to make your characters into strings,
> >> though, or cast them or something.
> >>
> >> -Rus
> >>
> >> >-----Original Message-----
> >> >From: Faisal Amlani [mailto:[EMAIL PROTECTED]]
> >> >Sent: Friday, July 28, 2000 2:46 PM
> >> >To: Palm Developer Forum
> >> >Subject: Integer conversion
> >> >
> >> >
> >> >Is there an easy command to convert an integer to a charager?
> >> >i.e. 1 to "1"
> >> >and 42 to "42".
> >> >
> >> >FrmSetTitle (form, "Set # ");
> >> >
> >> >And I want to append the string with the number so the
> >title gives the
> >> >number "set" the user is currently accessing of the database.
> >> >
> >> >
> >> >
> >> >--
> >> >For information on using the Palm Developer Forums, or to
> >> >unsubscribe, please see
> >http://www.palmos.com/dev/tech/support/foru>ms/
> >> >
> >>
> >>
> >
> >
> >
> >--
> >
> >For information on using the Palm
> >Developer Forums, or to unsubscribe, please see
> >http://www.palmos.com/dev/tech/support/foru>ms/
> >
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/