Multiline define pattern
#1

Hello - this time I need help. I'm using something like:
pawn Код:
#define merge(%0,%1) \
    format(%0, sizeof(%0), %1)
Yup, I'm lazy. Anyway: it works fine for something like:
pawn Код:
new str[32];
merge(str, "%s: %s", "Pancakes are", "AWESOME");
But sometimes in my script I have something like:
pawn Код:
new str[499+1];
merge(str, "%s, %d, %s, %s, %s, %d, $%d, $%d",
UData[playerid][uname], UData[playerid][age], UData[playerid][sex], "Something", UData[playerid][strength], UData[playerid][uid], UData[playerid][cash], UData[playerid][bank_cash]);
Format accepted my multline syntax, but define didn't and I get
Quote:

error 017: undefined symbol "merge"

Can I somehow make define to respect multiline syntax too?
Reply
#2

Know when to use functions and when to use definitions! You need a function that can take a variable number of parameters. But honestly, don't be lazy and just type that shit out. A function will also be slower.
Reply
#3

Well, as you can read in wiki
Quote:

One interesting fact about the parameters is that if you have too many, the last one is all the extra ones.

I don't want a function, I just want silent substitution
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)