How can i put carriage return in a string using szCatStr or is it possible. In other words i want to seperate string info into different lines.
And most importantly will it work with the DrawText api.
Don't want to investigate consoles right now. Just using client area of standard window.
thanx in advance
And most importantly will it work with the DrawText api.
Don't want to investigate consoles right now. Just using client area of standard window.
thanx in advance
I think you have to do the parsing yourself and copy / insert the text you got into a new buffer.
szCatStr can only add to the end of a String and not insert in the middle of it. DrawText will work with any Text no matter how many CRLF's there are.
szCatStr can only add to the end of a String and not insert in the middle of it. DrawText will work with any Text no matter how many CRLF's there are.
Well if you're going to use szCatStr, can't you just use a string containing a crlf?
.data
string1 db "stuff",0
string2 db "more stuff",0
crlf db 13,10,0 ;or is that 10,13?
buffer db 64 dup(0)
.......
......
.....
invoke szCatStr,addr buffer,addr string1
invoke szCatStr,addr buffer,addr crlf
invoke szCatStr,addr buffer,addr string2
invoke szCatStr,addr buffer,addr crlf
invoke MessageBox,0,addr buffer,0,0
.....
....
....
.data
string1 db "stuff",0
string2 db "more stuff",0
crlf db 13,10,0 ;or is that 10,13?
buffer db 64 dup(0)
.......
......
.....
invoke szCatStr,addr buffer,addr string1
invoke szCatStr,addr buffer,addr crlf
invoke szCatStr,addr buffer,addr string2
invoke szCatStr,addr buffer,addr crlf
invoke MessageBox,0,addr buffer,0,0
.....
....
....
Will:
i tied your method and all it does is add characters to the string.
JimmyClif:
I tried putting a carriage return into a new buffer but no go.
i tied your method and all it does is add characters to the string.
JimmyClif:
I tried putting a carriage return into a new buffer but no go.
That's odd because right after I posted that code I actually threw together a little test app and the messagebox text looked like this:
stuff
more stuff
I've already deleted it, and can't remember if 10 is the cr or 13 is, but other than that it worked fine. Whether that'll work with DrawText I don't know, but the messagebox looked exactly like intended.
-shrugs-
stuff
more stuff
I've already deleted it, and can't remember if 10 is the cr or 13 is, but other than that it worked fine. Whether that'll work with DrawText I don't know, but the messagebox looked exactly like intended.
-shrugs-
IwasTitan,
maybe you should be more detailed what you wanna do :) Show us an example and the code you tried :)
maybe you should be more detailed what you wanna do :) Show us an example and the code you tried :)
Titan,
The szCatStr proc works fine but if you need to concantenate a number of strings which include the CRLF pair, have a look at a procedure written by Alex (The Svin) called szMultiCat as it is very powerful and fast with this type of work.
Set up a buffer that is big enough to hold all of the string data you need and write a zero at the beginning so that it is read as a zero length string then use szMultiCat to appens as much as you like to it.
Write ascii 13 and 10 and 2 zeros to the CRLF buffer and then set up the szMultiCat proc to take each string and CRLF to get the string you want.
If it is string data that is fixed you can just write it in the .DATA section.
Regards,
hutch@movsd.com
The szCatStr proc works fine but if you need to concantenate a number of strings which include the CRLF pair, have a look at a procedure written by Alex (The Svin) called szMultiCat as it is very powerful and fast with this type of work.
Set up a buffer that is big enough to hold all of the string data you need and write a zero at the beginning so that it is read as a zero length string then use szMultiCat to appens as much as you like to it.
LOCAL buffer{256]:BYTE ; allocate a buffer
LOCAL CRLF[4]:BYTE
Write ascii 13 and 10 and 2 zeros to the CRLF buffer and then set up the szMultiCat proc to take each string and CRLF to get the string you want.
If it is string data that is fixed you can just write it in the .DATA section.
MyString db "Line one",13,10
db "Line two",13,10
db "Last line",0
Regards,
hutch@movsd.com
I did a search for szMultiCat procedure but can't find a posting of the source code.
Any directional tips welcome.
Any directional tips welcome.
I did a search for szMultiCat procedure but can't find a posting of the source code.
Any directional tips welcome.
Erm... you looked at the source code for the masm32.lib? :grin:
ok..thought i did that
will retry
will retry
Titan,
Here is a macro for simplifying the use of szMultiCat.
Regards,
hutch@movsd.com
Here is a macro for simplifying the use of szMultiCat.
; ------------------------------------------------------
; macro for concantenating strings using the szMultiCat
; procedure written by Alexander Yackubtchik.
;
; USAGE strcat buffer,str1,str2,str3 etc ...
;
; buffer must be large enough to contain all of the
; strings to append. Limit is set by maximum line
; length in MASM.
; ------------------------------------------------------
strcat MACRO arguments:VARARG
txt equ <invoke szMultiCat,> ;; lead string
pcount = 0
FOR arg, <arguments>
pcount = pcount + 1 ;; count arguments
ENDM
% pcount = pcount - 1 ;; dec 1 for 1st arg
txt CATSTR txt,%pcount ;; append number to lead string
FOR arg, <arguments>
IF @InStr(1,<arg>,<ADDR>) ne 0
txt CATSTR txt, <,arg>
ELSE
txt CATSTR txt, <,ADDR arg> ;; append 'ADDR' + args
ENDIF
ENDM
txt ;; put result in code
ENDM
Regards,
hutch@movsd.com
thank you.
Am i to take it that szMultiCat is in the masm32 library. I didn't see it in masm32lib.hlp. list.
I don't have it in any library. Did it come with the latest version of masm32?
Can someone post the original here so i can put it in the library.
:alright:
Am i to take it that szMultiCat is in the masm32 library. I didn't see it in masm32lib.hlp. list.
I don't have it in any library. Did it come with the latest version of masm32?
Can someone post the original here so i can put it in the library.
:alright:
Attached :)
PROTOTYPE
szMultiCat PROTO C :DWORD,:DWORD,:VARARG
It is in the standard installation of MASM32 v 7 so you may be using an earlier version.
Regards,
hutch@movsd.com
PROTOTYPE
szMultiCat PROTO C :DWORD,:DWORD,:VARARG
It is in the standard installation of MASM32 v 7 so you may be using an earlier version.
Regards,
hutch@movsd.com
Thanx
No i don't think i'm using version 7
No i don't think i'm using version 7