Does anyone know of a quick way to add a CR/LF to the end of a declared string during runtime. I looked at the MASM lib and there is a function called szcatstr but I get an illegal operation as soon as I call it. I am trying to get a users data from an edit control (i got that part done already) and then pass it to a procedure which will add the CR/LF portion to the string that the user entered and then place that text into another edit control. Thanks in advance, Devin
You can use lstrcat for this, something like: .data? Buffer db 200 dup (?) .data CRLF db 0dh,0ah,0 .code ; --- when text from edit control is in Buffer -- invoke lstrcat, ADDR Buffer, ADDR CRLF I guess you could use szcatstr as well, maybe the illegal operation was because there was not enough space in the buffer, or you might have forgotten the terminating zero for the CRLF string. Thomas
Devin, To use the szCatStr() procedure in the MASM32 library, you need to ensure that you sert up the zero terminated strings correctly. This is from the help file for masm32lib. Description szCatStr appends the second zero terminated string (lpszAdd) to the end of the first zero tereminated string (lpszSource). The result is zero terminated. Comments It is the users responsibility to ensure that the buffer for the source string is large enough to accept the appended string. Failure to do this will end up with a write page fault. The API call will also do the job but szCatStr() will be noticably faster if you have to recursively call it, especially if the appended strings are long. If you put in your .DATA section, CRLF db 13,10,0 You can append that to the end of any ZERO terminated string you like and the result will also be a zero terminated string. You must make sure the first string is in a buffer large enough to accept the second one otherwise you will get a page write fault when the write goes past the end of the buffer. Regards, email@example.com
I think that lstrcat is too long for a simple job i would do : (if your string is in buffer) invoke StrLen, ADDR buffer add eax, offset buffer mov BYTE PTR , 13 mov BYTE PTR , 10 mov BYTE PTR , 0
To scalp: following your logic but in short way: invoke StrLen, ADDR buffer mov dword ptr buffer,0A0Dh Using another algo logic will make it even faster. The Svin.