im fiddling around with parsing text that is in a richedit control, just trimming the spaces for now. currently im getting each line of text with EM_GETLINE and then parsing it.

the problem{maybe not) is that i would need to write the parsed text back to the same line and overwrite the orginal line and do this all the way till end of text/lines. is this an efficient way to do this or is there a better method to do such a thing? should i read all the text into a single buffer, parsing the info and then write it back into the richedit control?

not sure if this post is clear enough. if not just say so.
Posted on 2002-06-13 11:56:05 by smurf
Sounds like a trim-trailing spaces feature...I can't think of better methods other than reading a line of text, parse, write it back. Putting the whole entire text of an edit control into a buffer would cost a lot of memory space...

Reading a line, parse... is much slower but would compensate for less memory usage.
Posted on 2002-06-13 12:39:59 by stryker
Hi smurf

What about allocating a memory buffer and put the parsed text into it, line for line. Then when done parsing, replace the richedit content with the content of the memory buffer.

KetilO
Posted on 2002-06-13 12:42:34 by KetilO
I'm working on a project which needs to do the same thing.
I find it's quicker and simpler to have all the text in a buffer do the operations on it then write it to the edit window...
Posted on 2002-06-13 12:45:59 by MArtial_Code
I have a similar routine in my mail client.
I read the whole text into a buffer first, then delete every occurence of a space after a space (in fact: doublespaces) and every space after / before a 0Ah / 0Dh.
Of course, you can switch this off :)
Posted on 2002-06-13 12:50:45 by bazik
thanks for the suggestions. im gonna do some testing to see which is gonna work best. i can see where very large files can pose a memory problem when filling a single buffer.

another question:
to remove a space i would just put a zero into the address of the space?
Posted on 2002-06-13 13:09:15 by smurf
That's what I do but the edit control loads data upto the first encountered NULL. so you'll have to filter out the extraneous NULLs which you added...
Posted on 2002-06-13 13:13:03 by MArtial_Code

to remove a space i would just put a zero into the address of the space?


Use two buffers. Adding a 0h will, like MC said, terminate the string where you dont want it to be terminated :)
Posted on 2002-06-13 17:10:40 by bazik
Smurf this won't by any chance have anything to do with converting header files would it?
Posted on 2002-06-13 17:21:47 by MArtial_Code
no it doesnt MArtial_Code. if your interested though i have the commctrl.h, commdlg.h, winbase.h, winerror.h, wingdi.h, winuser.h and accctrl.h header files converted so far. im giving myself a break though from converting them because it takes alot of time. i left out the unicode crap though.

thanks bazik for clearing that up i was slightly confused on what i should do. now i realize that i just need to move anything i want over to the new buffer and leave out anything i dont want.
Posted on 2002-06-13 17:39:54 by smurf