From: Jen on 22 Aug 2006 20:18 Joseph ~ Thank you for your advice. I have read several of your articles and found them very helpful. Unfortunately I still haven't tracked this problem down. After reading your articles, I realized there may be a key to solving this problem. The program works fine in Debug mode, and only crashes in Release mode. I tried the checking the Heap in several places including OnIdle in the debug version, and everything worked okay. Does knowing that give you any other things for me to try? I did turn off all optimizations and Rebuild All, but the program still crashed at the end. I didn't turn on the debug in release mode, because I didn't know where to try to debug since it crashes at the end. Thanks again!! Jennifer
From: Jen on 22 Aug 2006 20:22 Ed, I am using VS6, so this definitely sounds like it could be a possible cause of my trouble. However, I am not sure how to implement it. First I need to malloc a buffer. Then sprintf into it, and then add it to the CString. Is that correct? I have a few places where I directly assign text into the CString. Would I keep that as is, and only modify those .Format commands containing %d? Thanks for the help. Jen
From: Ajay Kalra on 22 Aug 2006 21:32 queryStr.Format("Avg(IIf(E1.Param%d=0,0,(T1.Param%d-E1.Param%d)/(E1.Param%d)*100))",paramNum+1,paramNum+1,paramNum+1,paramNum+1); Can you step in this method and see if this is working correctly. Is the string as you expect after this function call? --- Ajay
From: Ed Weir (ComCast) on 22 Aug 2006 21:49 "Jen" <leonard522(a)aol.com> wrote in message news:1156292545.979110.54370(a)74g2000cwt.googlegroups.com... | | Ed, | I am using VS6, so this definitely sounds like it could be a possible | cause of my trouble. However, I am not sure how to implement it. | | First I need to malloc a buffer. Then sprintf into it, and then add it | to the CString. Is that correct? I have a few places where I directly | assign text into the CString. Would I keep that as is, and only modify | those .Format commands containing %d? | | Thanks for the help. | Jen The bug in the strex parser is very obscure. Because of that, it is only necessary to implement the workaround where .Format is actually causing a problem. As I mentioned in my last reply to Joe, use _stprintf to do the work and new TCHAR [nSize]/delete for memory blocks as needed. Another option is to use GetBuffer/ReleaseBuffer members of CString (ref: see the MSDN help on CString..) to get the memory to _stprintf(pBuffer, pszFormat, ....) your formatted text into. Keep in mind that if you specify a memory buffer size for text you should use sizeof(TCHAR) as the multiplier for the size unless you use new to allocate the memory. Hope I haven't muddled it all up too badly for you... 8^) If so, I will be glad to give an example for you: CString str; LPTSTR pBuffer = str.GetBuffer(nSize * sizeof(TCHAR)); // or 8192... _stprintf(pBuffer, _T("String data format stuff %d yada yada%ul etc.") ... str.ReleaseBuffer(); - and you're good to go. Let me know if this solves the problem! -- Ed. ----------------------------------------------------- In dictatorships, you need courage to fight evil; in the free world, you need courage to see the evil." ?Natan Sharansky F9E7707A2AF502D0A899C6ACB43A2D35EB7E->bin->b64
From: Ed Weir (ComCast) on 22 Aug 2006 21:57
"Ajay Kalra" <ajaykalra(a)yahoo.com> wrote in message news:1156296764.122192.285940(a)i3g2000cwc.googlegroups.com... | queryStr.Format("Avg(IIf(E1.Param%d=0,0,(T1.Param%d-E1.Param%d)/(E1.Param%d)*100))",paramNum+1,paramNum+1,paramNum+1,paramNum+1); | | Can you step in this method and see if this is working correctly. Is | the string as you expect after this function call? | | --- | Ajay I built it into a sandbox (_MBCS) and it worked OK for me; that doesn't mean it's OK for her though... I could try it in UNICODE if needed later. - Ed. |