A lot of people using MASM have a background using a C compiler so a macro that does the formatting to handle newline and tab characters shoud be useful here. The macro is called by another far simper macro that displays the text once its formated. If a non quoted argument is passed to it, it returns that argment unmodified. The current version supports the following escapes,
\n newline
\t tab
\q quote
\\ a displayed backslash
[attachment deleted by admin]
Hi Hutch,
Thanks for the macros, they work fine :U
Here is the second version, this one displays the results in a messagebox which is a macro that uses the C style sting formatting macro. This one addresses the characters that masm's own internal parser uses so the list of escapes is larger. As Greg pointed out the 13,10 for Newline is not C standard but its more useful in more places to have the character par than just an ascii 10 so I have retained the 13,10.
This is the list of escapes.
\n = newline
\t = tab
\\ = \
\q = quote
\l = <
\r = >
\x = !
\a = (
\b = )
The main macro which is reasonably large is designed as a component of other much simpler macros and this is shown in the test macro for the messagebox.
cmsgbox MACRO hndl,msgtxt,ttltxt,styl
invoke MessageBox,hndl,fmtcstr(msgtxt),reparg(ttltxt),styl
ENDM
It should be reasonably easy to use for constructing other macros that can use a formatted C style string.
[attachment deleted by admin]
It works :U
just to point out.. in C ...
\r is usually used for carriage-return (13)
\n is therefore linefeed (10)
\a is alert/bell (07)
\b is backspace (08)
But this is of little consequence except to convention :toothy
also...
\x it for hex numbers. ;)
Guys,
Thanks for the feedback, because of the number of dedicated escapes that masm uses it is not possible to properly emulate the C standard as it needs the extra list of escapes to handle characters that masm does not allow in normal quoted text. I understood Greg's comment on \n = 10 but my thinking was that \n = 13,10 is a lot more general purpose in that it can be used in any string based API call and it can be redirected to file if its for STDOUT.
I am less worried about it conforming to the C standard than I am of making it similar to use given that it will be documented properly. By making the macro a component that can be used by other macros, it allows macros for combined text and converted numbers in whatever context is useful.