RE: newline in string resource
StrChr is an instruction which allow you to search a character within a string. So, in the example you gave, StrChr ( msg, '\n' ), will return the address where the character '\n' can be found in msg. If you want to add '\n' in msg you should use StrCat. == StrCat ( msg, \n ); // becareful the second argument is a string Cordialement, Agus Silas BST Technologies T. (+33) 5 57 80 16 03 F. (+33) 5 57 77 29 97 http://www.bst-technologies.com -Message d'origine- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]De la part de Richard Coutts Envoyé : mardi 10 septembre 2002 05:42 À : Palm Developer Forum Objet : Re: newline in string resource I have a string resource that I would like to add some simple formatting to with newlines. Is this possible? I'm using \n but am getting errors. Not sure if this will help you at all, but here's a function I coded recently (I took out some superfluous stuff, so test it if you use it). // // Equivalent of WinDrawChars but handles newlines (lifted from PalmOS.com) // void cfDrawChars(Char* msg, short xp, short yp) { Char* c; UInt16 msgLen; while (msg) { c = StrChr(msg, '\n'); if (c == NULL) msgLen = StrLen(msg); else { msgLen = c-msg; c++; } WinPaintChars(msg, msgLen, xp, yp); yp += FntLineHeight(); msg = c; } } -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/ -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: newline in string resource
StrChr is an instruction which allow you to search a character within a string. If you want to add '\n' in msg you should use StrCat. Agus, As Joe pointed out in this thread, WinDrawChars will not process a newline character ('\n') as one might expect and will instead keep all of the text on a single line, rendering a box character where the newline characters appear in the string. The function I posted is an alternative to WinDrawChars that will process a newline character.That is why StrChr (and not StrCat) is used -- to find the location of the newline characters in the string. You should make the attempt to understand what the code does before posting corrections. -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
newline in string resource
I have a string resource that I would like to add some simple formatting to with newlines. Is this possible? I'm using \n but am getting errors. John Mc -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: newline in string resource
At 03:47 PM 9/9/2002 -0400, you wrote: I have a string resource that I would like to add some simple formatting to with newlines. Is this possible? I'm using \n but am getting errors. Where do you get your errors? Compile time or runtime? What kind of errors are they? -- Ben Combee [EMAIL PROTECTED] CodeWarrior for Palm OS technical lead Palm OS programming help @ www.palmoswerks.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: newline in string resource
--- John McDowell [EMAIL PROTECTED] wrote: I have a string resource that I would like to add some simple formatting to with newlines. Is this possible? I'm using \n but am getting errors. If you are using Constructor, just hit the Enter/Return key where you want to insert the newline in your string. How are you trying to display the string on your handheld? This won't work: Char str[] = abc\ndef; WinDrawChars( str, StrLen(str), 10, 100 ); because WinDrawChars doesn't know what to do with unprintable chars. This will work: Char str[] = abc\ndef; SetFieldTextFromStr( MainForm, MainFField, str, true ); if MainFField is a multi-line field (and if you write the SetFieldTextFromStr function), because fields know what to do with '\n'. __ Do You Yahoo!? Yahoo! Finance - Get real-time stock quotes http://finance.yahoo.com -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
Re: newline in string resource
I have a string resource that I would like to add some simple formatting to with newlines. Is this possible? I'm using \n but am getting errors. Not sure if this will help you at all, but here's a function I coded recently (I took out some superfluous stuff, so test it if you use it). // // Equivalent of WinDrawChars but handles newlines (lifted from PalmOS.com) // void cfDrawChars(Char* msg, short xp, short yp) { Char* c; UInt16 msgLen; while (msg) { c = StrChr(msg, '\n'); if (c == NULL) msgLen = StrLen(msg); else { msgLen = c-msg; c++; } WinPaintChars(msg, msgLen, xp, yp); yp += FntLineHeight(); msg = c; } } -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/