Okay, here's the complete relevant snippet:

                char str[100]; // Temporary string to hold data to be
displayed.

                // Determine the length of text that will fit within the
bounds.
                textLen = StrLen(pdb->strName);

                if (FntCharsWidth(pdb->strName,textLen) < width) 
                // If the string was short enough to fit wholly in the
cell...         
                {
                        StrCopy(str,pdb->strName);
                }
                else    
                // The string was too long to fit within the cell...
                {
                        width -= FntCharsWidth("...",3); // New width takes
into account addition of elipsis.
                        textLen = StrLen(pdb->strName); // Reset in case it
was tweaked.
                        FntCharsInWidth(pdb->strName, &width, &textLen,
&fits);                 
                
                        // Copy as many characters as will fit.
                        StrNCopy(str,pdb->strName,textLen);

                        // Append the elipsis ("...").
                        CharPtr pChar = str + textLen;          /*
Questionable code line 1 */
                        for (int loop = 0; loop < 3; loop++)    /*
Questionable code line 2 */
                                *(pChar++) = '.';                       /*
Questionable code line 3 */
                        *pChar = '\0';                          /*
Questionable code line 4 */

//                      StrCat(str,"...");
                        textLen = StrLen(str);
                }

If I cut out all the 'Questionable code' lines and uncomment the StrCat()
call, it stops functioning correctly.  I'll get strange artifacts like a
colon, THEN the three periods following my string rather than just the three
periods!  These artifacts (though randomly distributed among my strings)
consistently appear and disappear each time I switch between the two
methods.

If I'm calling something incorrectly, I don't see it.

Jeff

> -----Original Message-----
> From: Scott L. Johnson [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, May 05, 2000 2:19 PM
> To:   Palm Developer Forum
> Subject:      RE: Bug in StrCat()?
> 
> > From: Fitzsimons, Jeff [mailto:[EMAIL PROTECTED]]
> > StrCat() seemed to work only once in
> > a while.  Sometimes it would copy the '...' properly and 
> > other times it would copy in junk
> > 
> > Anyone else see behavior like this, or am I just committing 
> > one of those unbelievably simple beginner programmer mistakes 
> 
> Can you post the code that calls StrCat?  It's extremely unlikely that the
> StrCat function itself is broken, so...  :-)
> 
> -slj-
> 
> 
> -- 
> 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/

Reply via email to