At 7:00 PM +1100 on 3/6/99, Darren Beck wrote:

> A while ago I asked the list if it was possible to write a letter 
> in the Graffiti area and have that select the first item starting 
> with that letter in a sorted Popup list. With a great deal of help 
> from people on ths list, here's one way to do it. It's rude crude 
> and unedited but it seems to be working so far in CityTime 2.1, 
> even though it could use a bit of fixing.
> ...
>   // intercept it only if appropritate
>    if (event->eType == keyDownEvent && event->data.keyDown.chr > 64 &&
>      event->data.keyDown.chr < 123)
>     {
>     // setup key string - need a string for FindCityByLetter
>      keyS = MemPtrNew (2);
>      ErrFatalDisplayIf (!keyS, "error allocating memory");
>
>      keyS[0] = event->data.keyDown.chr;
>      keyS[1] = '\0';
>
>     // get the character
>      i = FindCityByLetter (keyS);

Have you considered changing the "FindCityByLetter" routine to take a 
Char parameter instead of a string?

Alternatively, how about allocating keyS as a stack-based (local) 
variable [character array] instead of a CharPtr?

Reply via email to