Thread: [Solved] define replace
View Single Post
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-09-2017 , 14:45   Re: define replace
Reply With Quote #7

And you can do
Code:
#define client_print(%0) whatever(%0)
without getting any errors. The preprocessor just performs find-and-replace with given patterns, it has no knowledge of symbols (meaning it doesn't care if they were already defined) as far as I am aware.

However, your example
Code:
#define client_print(%1,print_chat,%2)     color_print(%1, true, %2)
won't work well as it won't match text like:
Code:
client_print(0, print_chat, "");
client_print(0,print_chat ,"");
because the pattern also takes whitespace into account, meaning that if there isn't exactly ",print_chat," in there, it won't match. Probably the best way to deal with that is to do
Code:
#define client_print(%0,%9print_chat%8,%1) color_print(%0, true, %1)
macro parameters pretty much work like ".*" expression in Regex.

Last edited by klippy; 09-09-2017 at 14:45.
klippy is offline