A89: Re: Re: A C question
[Prev][Next][Index][Thread]
A89: Re: Re: A C question
Actually, the reason my method did not work is because when
ev->extra.pasteText was pointed to a string (by the default event handler),
it was pointing to a string in ROM (e.g. "sin(", "cos(", "taylor("). I
fixed it like this:
if(ev->extra.pasteText[strlen(ev->extra.pasteText)-1] == '(')
{
char *string="";
strcpy(string,ev->extra.pasteText);
string[strlen(string)-1] = (char)0;
ev->extra.pasteText = string;
}
which copies the constant string to a different address, allowing it to be
changed, and then points ev->extra.pasteText to the new address. Now, it is
giving me some other wacky error that I can't figure out. Aargh.
Thanks for your help though, I hadn't even thought about that method.
----- Original Message -----
From: "Brian Maxwell" <bmaxwell@remc11.k12.mi.us>
To: <assembly-89@lists.ticalc.org>
Sent: Friday, June 23, 2000 5:19 PM
Subject: A89: Re: A C question
>
> instead of this:
> ev->extra.pasteText[strlen(ev->extra.pasteText)-1] = '\0';
>
> use this:
> strcpy(ev->extra.pasteText + (strlen(ev->extra.pasteText)-1), "\0");
>
> and that should remove the ")" at the end.
>
> ----- Original Message -----
> From: Mike Grass
> To: Assembly-89
> Sent: Wednesday, June 21, 2000 12:41 AM
> Subject: A89: A C question
>
>
> Hmm, any thoughts as to why this doesn't work? I am trying to strip off
the
> '(' character at the end of the string by writing a null character over
it,
> but when I try the code, it leaves the '(' character at the end. Anyway,
I
> have some other code that does basically the same thing, and it does work,
> and I can't figure out why this doesn't work.
> EVENT *ev;
> ......
> if(ev->extra.pasteText[strlen(ev->extra.pasteText)-1] == '(')
> {
> ev->extra.pasteText[strlen(ev->extra.pasteText)-1] = '\0';
> printf("%s",ev->extra.pasteText);
> ngetchx();
> }
>
>
>
References: